Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_imp.cpython-39.opt-1.pyc

a

��g�F�@sddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
Z
ddlZe���$e�
de�ddlZWd�n1s�0YddlZdd�ZGdd�de
j�ZGd	d
�d
e
j�ZGdd�de
j�ZGd
d�de
j�ZGdd�de
j�Zedk�re
��dS)�N)�support)�
script_helper�ignorecCs"t�|�}t�ttd�d�|�S)zXDecorator to skip a test if not running under CPython or lacking
    imp.load_dynamic().�load_dynamiczimp.load_dynamic() required)r�cpython_only�unittest�skipIf�hasattr�imp)�meth�r�)/usr/local/lib/python3.9/test/test_imp.py�requires_load_dynamics
��rc@s eZdZdZdd�Zdd�ZdS)�	LockTestsz)Very basic test of import lock functions.cCs|�t��|d|�dS)Nz!expected imp.lock_held() to be %r)�assertEqualr
�	lock_held)�self�expectedrrr
�verify_lock_states�zLockTests.verify_lock_statecCs�d}t��}|�|�t|�D]}t��|�d�qt|�D]}t��q>|�|�|s�zt��WntyxYn0|�d�dS)N�2Tz5release_lock() without lock should raise RuntimeError)r
rr�range�acquire_lock�release_lock�RuntimeErrorZfail)rZLOOPSZlock_held_at_start�irrr
�testLock s


zLockTests.testLockN)�__name__�
__module__�__qualname__�__doc__rrrrrr
rsrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
edd��Zedd��Z
edd��Zedd��Zedd��Ze�ejd�dd��Zdd�Zd d!�Zejd"d#��Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,S)-�ImportTestscCst�d�}|j|_|j|_dS)Nztest.encoded_modules)�	importlib�
import_module�test_strings�__path__�	test_path)r�modrrr
�setUp<s
zImportTests.setUpcCs2|jD]&\}}}t�d|�}|�||j�qdS)Nztest.encoded_modules.module_)r#r!r"r�test)r�modname�encodingZteststrr&rrr
�test_import_encoded_moduleAs
�z&ImportTests.test_import_encoded_modulec	Cs�|jD]N\}}}t�d||j�d�}|�|j|�Wd�q1sJ0Yqtj�t	�g}|�
t��t�d|�Wd�n1s�0YdS)N�module_r�badsyntax_pep3120)r#r
�find_moduler%rr*�os�path�dirname�__file__�assertRaises�SyntaxError)rr&r*�_�fdr0rrr
�test_find_module_encodingGs.z%ImportTests.test_find_module_encodingc	Cs�|jD]�\}}}t�d||j�\}}}|�N|�|d�|�|j|�|�|��d�|�|��d|�Wd�q1s�0Yqt�d�\}}}|�J|�|d�|�|jd�|�|��d�|�|��d�Wd�n1s�0YdS)Nr,rz# test %s encoding
�tokenize�utf-8z*"""Tokenization help for Python programs.
)	r#r
r.r%ZassertNotEqualrr*�tell�readline)rr&r*r5�fp�filename�inforrr
�test_issue1267Ps&
�
�&
�zImportTests.test_issue1267c
Cs�d}tj�dd�z�t|dd��}|�d�Wd�n1sB0Yt�|�\}}}|��|�|j	d�Wtjd=t
�|d�t
�|d�n&tjd=t
�|d�t
�|d�0dS)	NZtest_imp_helperr�.�.py�wz%# coding: cp1252
u = 'test.test_imp'
�cp1252�.pyc)�sysr0�insert�open�writer
r.�closerr*r�unlink)r�
temp_mod_name�filer=r>rrr
�test_issue3594cs(�zImportTests.test_issue3594cCsVt��}ddddddddddd�
}tjdkr>|�|d�d	}n
|�|�}|sZ|�d
|�|�|�}d|}d|}tj�	|d
�}�z�tj�
dtj�t|dd��}|�
d�Wd�n1s�0Yt�|�\}}	}
|��|�|�|�|	dd��|��|�|
dd�|�|
dd�|�|
dtj�t�|||	|
�}|�|jd�Wd�n1�sl0Yt���*t�d�t�||d�}Wd�n1�s�0Y|�|jd�t���8t�d�tj�s�t�|t�|d��}Wd�n1�s0Y|�|jd�tj�|��s@t�|�t|d��}|�
d�Wd�n1�sl0Yt���&t�d�t�||�}Wd�n1�s�0Y|�|j d�Wtjd=dD]"}
t!�"||
�t!�"||
��q�t!�#|�t!�#d�nFtjd=dD]"}
t!�"||
�t!�"||
��qt!�#|�t!�#d�0dS)Ns�������)
r9�cp1250�cp1251rC�cp1253�cp1254�cp1255�cp1256�cp1257�cp1258�darwinr9säz2can't run this test with %s as filesystem encodingZtest_imp_helper_Ztest_imp_helper_package_z__init__.pyrrArBza = 1
�����r�rzb = 2
)rArD�__pycache__)$rE�getfilesystemencoding�platformr�get�skipTest�decoder/r0�joinrF�curdirrGrHr
r.ZassertIsNotNoneZ
assertTrue�endswithZ	PY_SOURCE�load_module�a�warnings�catch_warnings�simplefilter�load_source�dont_write_bytecodeZ
load_compiled�cache_from_source�exists�mkdirZload_package�brrJ�rmtree)rZfs_encodingZ
known_localesZspecial_charZdecoded_charrKZtest_package_nameZinit_file_namerLr=r>r&�package�extrrr
�test_issue5604qs��

�
(
.

0

�$
*

,
�
zImportTests.test_issue5604cCs$tj�t�}|�ttjd|g�dS)Nr-)r/r0r1r2r3r4r
r.)rr0rrr
�test_issue9319�s
�zImportTests.test_issue9319cCs�tj}tj}t���dt�d�}|�|dj�tj	dg|�R�}|�
t|�|�
||j�|�||j�Wd�n1s~0YdS)Nr/r)r/r0�getenvr�EnvironmentVarGuardr
r.�
addCleanuprIrh�assertIsZassertIsNot)r�	orig_pathZorig_getenv�xZnew_osrrr
�test_load_from_source�s	

z!ImportTests.test_load_from_sourcecCsNd}t�|�}|d}|dur*|�|j�tj|g|�R�}|�|j|�dS)N�_heapqr)r
r.rzrIrhrr)rZexampler}Zfile_r&rrr
�test_issue15828_load_extensions�s
z+ImportTests.test_issue15828_load_extensionscCs�d}t�|�\}}}|��t�||�}t�d|�}t�d|�}|�|j|�|�|jd�|�|jd�|�t��t�d|�Wd�n1s�0YdS)N�_testimportmultipleZ_testimportmultiple_fooZ_testimportmultiple_barZnonexistent)r
r.rIrrrr3�ImportError)r�m�fileobj�pathname�descriptionZmod0Zmod1Zmod2rrr
�+test_issue16421_multiple_modules_in_one_dll�sz7ImportTests.test_issue16421_multiple_modules_in_one_dllcCsbd}d}|�t��}t�||�Wd�n1s40Y|�||jj�|�||jj�dS)Nzbogus file path�	extension)	r3r�r
rZassertIn�	exceptionr0r�name)rr0r��errrrr
�"test_load_dynamic_ImportError_path�s*z.ImportTests.test_load_dynamic_ImportError_pathcCsbd}t�|�}|ddur&|d��|ddtjkrB|�d�tj|dg|dd��R�dS)Nr�rr^z/found module doesn't appear to be a C extensionr\)r
r.rIZC_EXTENSIONrcrh)rr��foundrrr
�'test_load_module_extension_file_is_Nones

z3ImportTests.test_load_module_extension_file_is_NonecCs�d}ztj|=Wnty"Yn0z�t�|�}tj�d�}t�||j	�}|�
|j|�|�
|jj
|�|�
|jj	|j	�|�tt|d�|�
|jd�|�tj||�Wztj|=Wq�ty�Yq�0n"ztj|=Wnty�Yn00dS)Nztest.imp_dummyZ_testmultiphaseZ
dummy_namei�)rE�modules�KeyErrorr!r"�util�	find_specr
r�originrr�__spec__r�r3�AttributeError�getattrZ	int_constr{)rr��module�specrrr
�3test_issue24748_load_module_skips_sys_modules_checks.
�z?ImportTests.test_issue24748_load_module_skips_sys_modules_checkz*test meaningful only when writing bytecodecCsXt���<tjd}t�|�|�tdtjtjdg�Wd�n1sJ0YdS)NrAz
^No moduler@)	r�temp_cwdZTESTFNr/rq�assertRaisesRegexr�r
r.)r�sourcerrr
�test_bug7732+s


�zImportTests.test_bug7732cCs2t�dtjttj��}|�tj�|�tj�dS)Nr
)r
Z_LoadSourceCompatibilityr2rG�get_data)r�loaderrrr
�test_multiple_calls_to_get_data4s

�z+ImportTests.test_multiple_calls_to_get_datac	Cs�dt��}ttjt�|�}t�tj||��L|�td�� t�	|t
d�Wd�n1s`0YWd�n1s~0YdS)N�tmpz
embedded null�)r�typerEr�rZ	swap_itemr��
ValueErrorr
rmr2)rr)r&rrr
�test_load_source;s

zImportTests.test_load_sourcecCsRt�td�}Gdd�d�}|�t��||��Wd�n1sD0YdS)N�create_dynamicc@seZdZdZdZdS)z,ImportTests.test_issue31315.<locals>.BadSpecN�foo)rrrr�r�rrrr
�BadSpecIsr�)rZ
get_attributer
r3�	TypeError)rr�r�rrr
�test_issue31315DszImportTests.test_issue31315cCs4ddl}|�|jjd�ddl}|�|jjd�dS)Nr�frozen)�_frozen_importlib_externalrr�r��_frozen_importlib)rr�r�rrr
�test_issue_35321OszImportTests.test_issue_35321cCs,|�t�dd�d�|�t�dd�d�dS)N�*shis��Z
:}��+s��65���9)r�_imp�source_hash)rrrr
�test_source_hashZszImportTests.test_source_hashcCshgdfddgdfddgdfddgdfg}|D]6\}}|ddg}tj|�}|�|j���d�|�q,dS)N�defaultz--check-hash-based-pycs�always�neverz-cz.import _imp; print(_imp.check_hash_based_pycs)r9)rZassert_python_okr�out�striprd)rZcasesZinterp_argsr�args�resrrr
�'test_pyc_invalidation_mode_from_cmdline^s


��
z3ImportTests.test_pyc_invalidation_mode_from_cmdlinec	Cs�t���~tdd��}|�d�Wd�n1s40Ytjddtjjd�tj	ddgd�\}}}t�
d|||�}Wd�n1s�0Y|�|jd	�dS)
Nzmymod.py�wbsx = 42
T)�doraise�invalidation_modeZmymodr@)r0r�)
rr�rGrH�
py_compile�compile�PycInvalidationMode�CHECKED_HASHr
r.rhrr})rr<rLr0r�r&rrr
�test_find_and_load_checked_pycms
(�.z*ImportTests.test_find_and_load_checked_pycN)rrrr'r+r7r?rMrvrwr~rr�r�r�r�r�rrrErnr�r�r�rrr�r�r�r�r�rrrr
r ;s<	W




�
	

r c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�ReloadTestszPVery basic tests to make sure that imp.reload() operates just like
    reload().cCs>t���"ddl}t�|�Wd�n1s00YdS)Nr)rryr/r
�reload)rr/rrr
�test_source�s
zReloadTests.test_sourcecCs@t�d��"ddl}t�|�Wd�n1s20YdS)N�timer)r�CleanImportr�r
r�)rr�rrr
�test_extension�szReloadTests.test_extensioncCs@t�d��"ddl}t�|�Wd�n1s20YdS)N�marshalr)rr�r�r
r�)rr�rrr
�test_builtin�szReloadTests.test_builtincshddlm}tj�d���fdd�}|�|�|�td��t�	|�Wd�n1sZ0YdS)Nr)�parser�htmlcs�tjd<dS)Nr�)rEr�r�r�rr
�cleanup�sz5ReloadTests.test_with_deleted_parent.<locals>.cleanup)
r�r�rEr��poprzr�r�r
r�)rr�r�rr�r
�test_with_deleted_parent�s
z$ReloadTests.test_with_deleted_parentN)rrrrr�r�r�r�rrrr
r�|s
r�c@sPeZdZdZe��Ze�e	j
jdud�dd��Ze�e	j
jdud�dd��Z
dS)	�PEP3147TestszTests of PEP 3147.Nz1requires sys.implementation.cache_tag not be Nonec	CsFtj�dddd�}tj�ddddd�|j��}|�t�|d�|�dS)Nr��bar�baz�qux.pyr_�
qux.{}.pycT)r/r0re�format�tagrr
ro�rr0�expectrrr
�test_cache_from_source�s

�z#PEP3147Tests.test_cache_from_sourcez4requires sys.implementation.cache_tag to not be Nonec	CsDtj�ddddd�|j��}tj�dddd�}|�t�|�|�dS)Nr�r�r�r_r�r�)r/r0rer�r�rr
�source_from_cacher�rrr
�test_source_from_cache�s

�z#PEP3147Tests.test_source_from_cache)rrrrr
Zget_tagr�rZ
skipUnlessrE�implementation�	cache_tagr�r�rrrr
r��s�
�r�c@s&eZdZe�ejdud�dd��ZdS)�NullImporterTestsNzNeed an undecodeable filenamec	Cs@tj}t�|�z|�ttj|�Wt�|�nt�|�0dS)N)	r�TESTFN_UNENCODABLEr/rqr3r�r
ZNullImporter�rmdir)rr�rrr
�test_unencodeable�s

z#NullImporterTests.test_unencodeable)rrrrrrr�r�rrrr
r��s�r��__main__)r!�importlib.utilr/Zos.pathr�rEr(rZtest.supportrrrjrkrl�DeprecationWarningr
r�rZTestCaserr r�r�r�r�mainrrrr
�<module>s.
&"C&


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists