HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/test_importlib/__pycache__/test_util.cpython-37.pyc
B

��g�{�@s�ddlmZe�d�Ze�d�Ze�d�Ze�d�ZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlZddlZGd	d
�d
�Zejeed�\ZZGdd�d�Zejeeeed
�\ZZGdd�d�Zejeed�\ZZGdd�d�Zejeed�\ZZGdd�d�Zejeed�\Z Z!Gdd�d�Z"eje"ed�\Z#Z$Gdd�d�Z%eje%eeed�\Z&Z'Gdd�d�Z(eje(ed�\Z)Z*Gdd�d�Z+eje+ed�\Z,Z-Gdd�dej.�Z(e/dk�r�e�0�dS)�)�utilz
importlib.abc�	importlibzimportlib.machineryzimportlib.util�N)�supportc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�DecodeSourceBytesTestsustring ='ü'cCs&|j�d�}|�|j�|�|j�dS)Nzutf-8)�source�encode�assertEqualr�
decode_source)�self�source_bytes�r
�9/usr/local/lib/python3.7/test/test_importlib/test_util.py�test_ut8_defaultsz'DecodeSourceBytesTests.test_ut8_defaultcCs>d|j}|�d�}||�d�ks&t�|�|j�|�|�dS)Nz# coding=latin-1
zlatin-1zutf-8)rr�AssertionErrorr	rr
)rrrr
r
r�test_specified_encodings

z.DecodeSourceBytesTests.test_specified_encodingcCsBd�|j|jg�}|�d�}|�|j�|�d�|j|jg��dS)Nz
zutf-8�
)�joinrrr	rr
)rrrr
r
r�test_universal_newlines s
z.DecodeSourceBytesTests.test_universal_newlinesN)�__name__�
__module__�__qualname__rrrrr
r
r
rrsrc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�ModuleFromSpecTestsc	CsDGdd�d�}|j�d|��}|�t��|j�|�}WdQRXdS)Nc@seZdZdd�ZdS)z9ModuleFromSpecTests.test_no_create_module.<locals>.LoadercSsdS)Nr
)r�moduler
r
r�exec_module0szEModuleFromSpecTests.test_no_create_module.<locals>.Loader.exec_moduleN)rrrrr
r
r
r�Loader/sr�test)�	machinery�
ModuleSpec�assertRaises�ImportErrorr�module_from_spec)rr�specrr
r
r�test_no_create_module.sz)ModuleFromSpecTests.test_no_create_modulecCsRGdd�d|jj�}|j�d|��}|j�|�}|�|tj�|�	|j
|j�dS)Nc@seZdZdd�ZdS)zCModuleFromSpecTests.test_create_module_returns_None.<locals>.LoadercSsdS)Nr
)rr"r
r
r�
create_module8szQModuleFromSpecTests.test_create_module_returns_None.<locals>.Loader.create_moduleN)rrrr$r
r
r
rr7srr)�abcrrrrr!�assertIsInstance�types�
ModuleTyper	r�name)rrr"rr
r
r�test_create_module_returns_None6s
z3ModuleFromSpecTests.test_create_module_returns_Nonecsjd�Gdd�dtj��G��fdd�d|jj�}|j�d|��}|j�|�}|�|��|�	|j
��dS)Nzalready setc@seZdZdS)z<ModuleFromSpecTests.test_create_module.<locals>.CustomModuleN)rrrr
r
r
r�CustomModuleAsr+cseZdZ��fdd�ZdS)z6ModuleFromSpecTests.test_create_module.<locals>.Loadercs�|j�}�|_|S)N)r)r)rr"r)r+r)r
rr$Ds
zDModuleFromSpecTests.test_create_module.<locals>.Loader.create_moduleN)rrrr$r
)r+r)r
rrCsrr)r'r(r%rrrrr!r&r	r)rrr"rr
)r+r)r�test_create_module?sz&ModuleFromSpecTests.test_create_modulecCs0|j�dt��}|j�|�}|�|j|j�dS)Nr)rr�objectrr!r	rr))rr"rr
r
r�
test___name__Msz!ModuleFromSpecTests.test___name__cCs.|j�dt��}|j�|�}|�|j|�dS)Nr)rrr-rr!r	�__spec__)rr"rr
r
r�
test___spec__Rsz!ModuleFromSpecTests.test___spec__cCs2t�}|j�d|�}|j�|�}|�|j|�dS)Nr)r-rrrr!�assertIs�
__loader__)r�loaderr"rr
r
r�test___loader__Wsz#ModuleFromSpecTests.test___loader__cCs0|j�dt��}|j�|�}|�|j|j�dS)Nztest.pkg)rrr-rr!r	�__package__�parent)rr"rr
r
r�test___package__]sz$ModuleFromSpecTests.test___package__cCs4|jjdt�dd�}|j�|�}|�|j|j�dS)NrT)�
is_package)rrr-rr!r	�__path__�submodule_search_locations)rr"rr
r
r�
test___path__bsz!ModuleFromSpecTests.test___path__cCs:|jjdt�dd�}d|_|j�|�}|�|j|j�dS)Nrz	some/path)�originT)	rrr-�has_locationrr!r	�__file__r<)rr"rr
r
r�
test___file__gsz!ModuleFromSpecTests.test___file__cCs<|j�dt��}d|_d|_|j�|�}|�|j|j�dS)Nrz	some/pathT)	rrr-�cachedr=rr!r	�
__cached__)rr"rr
r
r�test___cached__ms
z#ModuleFromSpecTests.test___cached__N)
rrrr#r*r,r.r0r4r7r;r?rBr
r
r
rr,s	r)r%rrc@sleZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�ModuleForLoaderTestsz+Tests for importlib.util.module_for_loader.c	Cs,t���t�dt�|j�|�SQRXdS)N�ignore)�warnings�catch_warnings�simplefilter�DeprecationWarningr�module_for_loader)�cls�funcr
r
rrI~s
z&ModuleForLoaderTests.module_for_loaderc
CsJt���8t�dt�|�t��|j�dd��}WdQRXWdQRXdS)N�errorcSs|S)Nr
)�xr
r
r�<lambda>��z3ModuleForLoaderTests.test_warning.<locals>.<lambda>)rErFrGrHrrrI)rrKr
r
r�test_warning�s
z!ModuleForLoaderTests.test_warningcCs|�dd��}|||�S)NcSs|S)Nr
)rrr
r
rrN�rOz4ModuleForLoaderTests.return_module.<locals>.<lambda>)rI)rr)�fxnr
r
r�
return_module�sz"ModuleForLoaderTests.return_modulecCs:dd�}|�|�}y|||�Wntk
r4YnXdS)NcSst�dS)N)r )rrr
r
r�to_wrap�sz5ModuleForLoaderTests.raise_exception.<locals>.to_wrap)rIr )rr)rSrQr
r
r�raise_exception�s
z$ModuleForLoaderTests.raise_exceptionc	CsRd}t�|��|�|�}|�|tj�WdQRX|�|tj�|�	|j
|�dS)Nza.b.c)r�uncacherR�assertIn�sys�modulesr&r'r(r	r)rZmodule_namerr
r
r�test_new_module�s
z$ModuleForLoaderTests.test_new_modulec	s�G�fdd�d�}d}t�d�}d|_d|_t�|��N|tj|<|�}|�|�}��	|tj|���
|j|���
|j|�WdQRXdS)Ncs"eZdZdd�Z�jdd��ZdS)z4ModuleForLoaderTests.test_reload.<locals>.FakeLoadercSsdS)NTr
)rr)r
r
rr8�sz?ModuleForLoaderTests.test_reload.<locals>.FakeLoader.is_packagecSs|S)Nr
)rrr
r
r�load_module�sz@ModuleForLoaderTests.test_reload.<locals>.FakeLoader.load_moduleN)rrrr8rIrZr
)rr
r�
FakeLoader�sr[za.b.c�*)r'r(r2r5rrUrWrXrZr1r	)rr[r)rr3Zreturned_moduler
)rr�test_reload�s


z ModuleForLoaderTests.test_reloadc	Cs6d}t�|��|�|�|�|tj�WdQRXdS)Nza.b.c)rrUrT�assertNotInrWrX)rr)r
r
r�test_new_module_failure�s
z,ModuleForLoaderTests.test_new_module_failurec	CsNd}t�|�}t�|��,|tj|<|�|�|�|tj|�WdQRXdS)Nza.b.c)r'r(rrUrWrXrTr1)rr)rr
r
r�test_reload_failure�s


z(ModuleForLoaderTests.test_reload_failurecCs6dd�}|�|�}|�|j|j�|�|j|j�dS)NcSsdS)Nr
)rrr
r
rrQ�rOz6ModuleForLoaderTests.test_decorator_attrs.<locals>.fxn)rIr	rr)rrQ�wrappedr
r
r�test_decorator_attrs�s
z)ModuleForLoaderTests.test_decorator_attrsc	CsbGdd�dtj�}d}||�}t�|��0|�|�|tj|<|�|�}|�||�WdQRXdS)Nc@seZdZdd�ZdS)z;ModuleForLoaderTests.test_false_module.<locals>.FalseModulecSsdS)NFr
)rr
r
r�__bool__�rOzDModuleForLoaderTests.test_false_module.<locals>.FalseModule.__bool__N)rrrrcr
r
r
r�FalseModule�srd�mod)	r'r(rrUZassertFalserWrXrRr1)rrdr)rZgivenr
r
r�test_false_module�s


z&ModuleForLoaderTests.test_false_modulec	s�G�fdd�d�}d}t�|��B|d�}|�|�}��|j|���|j|���|jd�WdQRXd}t�|��B|d�}|�|�}��|j|���|j|���|j|�WdQRXdS)Ncs*eZdZdd�Zdd�Z�jdd��ZdS)z<ModuleForLoaderTests.test_attributes_set.<locals>.FakeLoadercSs
||_dS)N)�_pkg)rr8r
r
r�__init__�szEModuleForLoaderTests.test_attributes_set.<locals>.FakeLoader.__init__cSs|jS)N)rg)rr)r
r
rr8�szGModuleForLoaderTests.test_attributes_set.<locals>.FakeLoader.is_packagecSs|S)Nr
)rrr
r
rrZ�szHModuleForLoaderTests.test_attributes_set.<locals>.FakeLoader.load_moduleN)rrrrhr8rIrZr
)rr
rr[�sr[zpkg.modF�pkgzpkg.subT)rrUrZr	rr1r2r5)rr[r)r3rr
)rr�test_attributes_set�s	

z(ModuleForLoaderTests.test_attributes_setN)rrr�__doc__�classmethodrIrPrRrTrYr]r_r`rbrfrjr
r
r
rrCzs	
	rCc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�SetPackageTestsz%Tests for importlib.util.set_package.c	s`�fdd�}|j�|�}t���t�dt�|�WdQRX|�t�d��|�|�j	�dS)zcVerify the module has the expected value for __package__ after
        passing through set_package.cs�S)Nr
r
)rr
rrNrOz(SetPackageTests.verify.<locals>.<lambda>rDNr5)
r�set_packagerErFrGrH�
assertTrue�hasattrr	r5)rr�expectrQrar
)rr�verifys
zSetPackageTests.verifycCs t�d�}d|_|�|d�dS)Nr�)r'r(r5rr)rrr
r
r�test_top_levels
zSetPackageTests.test_top_levelcCs(t�d�}dg|_d|_|�|d�dS)Nriz<path>)r'r(r9r5rr)rrr
r
r�test_packages
zSetPackageTests.test_packagecCs t�d�}d|_|�|d�dS)Nzpkg.modri)r'r(r5rr)rrr
r
r�test_submodules
zSetPackageTests.test_submodulecCs.t�d�}t|d�rt|d�|�|d�dS)Nrer5rs)r'r(rp�delattrrr)rrr
r
r�test_setting_if_missing s


z'SetPackageTests.test_setting_if_missingcCs.x(dD] }t�d�}||_|�||�qWdS)N)TFre)r'r(r5rr)r�valuerr
r
r�test_leaving_alone's

z"SetPackageTests.test_leaving_alonec	CsXdd�}t���t�dt�|j�|�}WdQRX|�|j|j�|�|j|j�dS)NcSsdS)Nr
)rr
r
rrQ/rOz1SetPackageTests.test_decorator_attrs.<locals>.fxnrD)	rErFrGrHrrnr	rr)rrQrar
r
rrb.s
z$SetPackageTests.test_decorator_attrsN)rrrrkrrrtrurvrxrzrbr
r
r
rrm�srmc@s4eZdZdZedd��Zdd�Zdd�Zdd	�Zd
S)�SetLoaderTestsz"Tests importlib.util.set_loader().csG�fdd�d�}|�j_|S)NcseZdZ�jjdd��ZdS)z/SetLoaderTests.DummyLoader.<locals>.DummyLoadercSs|jS)N)r)rrr
r
rrZDsz;SetLoaderTests.DummyLoader.<locals>.DummyLoader.load_moduleN)rrrr�
set_loaderrZr
)rr
r�DummyLoaderCsr})�	__class__r})rr}r
)rrr}@szSetLoaderTests.DummyLoaderc	Csl|��}t�d�|_y
|j`Wntk
r2YnXt���&t�dt	�|�
||�d�j�WdQRXdS)N�blahrD)r}r'r(rr2�AttributeErrorrErFrGrHr	rZ)rr3r
r
r�test_no_attributeJs

z SetLoaderTests.test_no_attributec	CsT|��}t�d�|_d|j_t���&t�dt�|�	||�
d�j�WdQRXdS)NrrD)r}r'r(rr2rErFrGrHr	rZ)rr3r
r
r�test_attribute_is_NoneUs
z%SetLoaderTests.test_attribute_is_Nonec	CsT|��}t�d�|_d|j_t���&t�dt�|�	d|�
d�j�WdQRXdS)Nrr\rD)r}r'r(rr2rErFrGrHr	rZ)rr3r
r
r�test_not_reset]s
zSetLoaderTests.test_not_resetN)	rrrrk�propertyr}r�r�r�r
r
r
rr{<s

r{c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�ResolveNameTestsz$Tests importlib.util.resolve_name().cCs|�d|j�dd��dS)N�bacon)r	r�resolve_name)rr
r
r�
test_absoluteoszResolveNameTests.test_absolutecCs|�d|j�dd��dS)Nr��spam)r	rr�)rr
r
r�test_absolute_within_packagessz-ResolveNameTests.test_absolute_within_packagec	Cs(|�t��|j�dd�WdQRXdS)Nz.baconrs)r�
ValueErrorrr�)rr
r
r�test_no_packagewsz ResolveNameTests.test_no_packagecCs|�d|j�dd��dS)Nzspam.eggs.baconz.baconz	spam.eggs)r	rr�)rr
r
r�test_in_package|sz ResolveNameTests.test_in_packagecCs|�d|j�dd��dS)Nz
spam.baconz..baconz	spam.eggs)r	rr�)rr
r
r�test_other_package�sz#ResolveNameTests.test_other_packagec	Cs(|�t��|j�dd�WdQRXdS)Nz..baconr�)rr�rr�)rr
r
r�test_escape�szResolveNameTests.test_escapeN)
rrrrkr�r�r�r�r�r�r
r
r
rr�ksr�c@szeZdZGdd�d�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
FindSpecTestsc@seZdZeddd��ZdS)zFindSpecTests.FakeMetaFinderNcCs
|||fS)Nr
)r)�path�targetr
r
r�	find_spec�sz&FindSpecTests.FakeMetaFinder.find_spec)NN)rrr�staticmethodr�r
r
r
r�FakeMetaFinder�sr�c	Cshd}t�|��Pt�|�}d}|j�||�}||_||_|tj	|<|j�
|�}|�||�WdQRXdS)N�some_modz	a loader!)rrUr'r(rrr2r/rWrXr�r	)rr)rr3r"�foundr
r
r�test_sys_modules�s

zFindSpecTests.test_sys_modulesc	Csfd}t�|��Nt�|�}|`d}|j�||�}||_|tj	|<|j�
|�}|�||�WdQRXdS)Nr�z	a loader!)rrUr'r(r2rrr/rWrXr�r	)rr)rr3r"r�r
r
r�#test_sys_modules_without___loader__�s

z1FindSpecTests.test_sys_modules_without___loader__c
CsZd}t�|��Bt�|�}d|_|tj|<|�t��|j�	|�WdQRXWdQRXdS)Nr�)
rrUr'r(r/rWrXrr�r�)rr)rr
r
r�test_sys_modules_spec_is_None�s

z+FindSpecTests.test_sys_modules_spec_is_Nonec	Cs^d}t�|��Ft�|�}|j�|d�}||_|tj|<|j�	|�}|�
||�WdQRXdS)Nr�)rrUr'r(rrr/rWrXr�r	)rr)rr"r�r
r
r�test_sys_modules_loader_is_None�s

z-FindSpecTests.test_sys_modules_loader_is_Nonec
Csrd}t�|��Zt�|�}y|`Wntk
r6YnX|tj|<|�t	��|j�
|�WdQRXWdQRXdS)Nr�)rrUr'r(r/r�rWrXrr�r�)rr)rr
r
r� test_sys_modules_spec_is_not_set�s

z.FindSpecTests.test_sys_modules_spec_is_not_setc
CsTd}t�|��<tj|jgd�� |�|ddf|j�|��WdQRXWdQRXdS)Nr�)�	meta_path)rrUZimport_stater�r	r�)rr)r
r
r�test_success�s
zFindSpecTests.test_successcCs|�|j�d��dS)NZnevergoingtofindthismodule)ZassertIsNonerr�)rr
r
r�test_nothing�szFindSpecTests.test_nothingc	Cs�d}d}tj|dd��l}t�|||�\}}|j�|�}|�|d�|�|ttj��|�	|ttj��|j�|�}|�
||�WdQRXdS)Nr��hamT)ri)r�temp_module�	submoduler��assertIsNotrV�sortedrWrXr^r	)rr)�subname�pkg_dir�fullname�_r"�
spec_againr
r
r�test_find_submodule�sz!FindSpecTests.test_find_submodulec	Cs�d}d}tj|dd��x}|j�|�t�|||�\}}|j�|�}|�|d�|�|tt	j
��|�|tt	j
��|j�|�}|�||�WdQRXdS)Nr�r�T)ri)
rr��init�
import_moduler�r�r�rVr�rWrXr^r	)rr)r�r�r�r�r"r�r
r
r�+test_find_submodule_parent_already_imported�sz9FindSpecTests.test_find_submodule_parent_already_importedc		Cs�d}d}tj|dd��v}t�|||�\}}d|}|j�||�}|�|d�|�|ttj��|�	|ttj��|j�|�}|�
||�WdQRXdS)Nr�r�T)ri�.)rr�r�r�r�rVr�rWrXr^r	)	rr)r�r�r�r��relnamer"r�r
r
r�test_find_relative_module�sz'FindSpecTests.test_find_relative_modulec
Cs�d}d}tj|dd��f}t�|||�\}}d|}|�t��|j�|�WdQRX|�|ttj	��|�|ttj	��WdQRXdS)Nr�r�T)rir�)
rr�r�rr�r�r^r�rWrX)rr)r�r�r�r�r�r
r
r�)test_find_relative_module_missing_packagesz7FindSpecTests.test_find_relative_module_missing_packagec	Cs&|�t��|j�d�WdQRXdS)Nzmodule.name)r�ModuleNotFoundErrorrr�)rr
r
r�test_find_submodule_in_module
sz+FindSpecTests.test_find_submodule_in_moduleN)rrrr�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr��s	

r�)r�rrc@seZdZdd�Zdd�ZdS)�MagicNumberTestscCs|�t|jj�d�dS)N�)r	�lenr�MAGIC_NUMBER)rr
r
r�test_lengthszMagicNumberTests.test_lengthcCs|�|jj�d��dS)Ns
)rorr��endswith)rr
r
r�test_incorporates_rn sz%MagicNumberTests.test_incorporates_rnN)rrrr�r�r
r
r
rr�sr�c@s<eZdZdZejjZe�	ejjdk	d�dd��Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Ze�	ejdko�ejdkd�dd��Ze�	ejjdk	d�dd��Ze�	ejjdk	d�d d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Z d0d1�Z!d2d3�Z"e�	ejjdk	d�d4d��ZdS)5�PEP3147TestszMTests of PEP 3147-related functions: cache_from_source and source_from_cache.Nz1requires sys.implementation.cache_tag not be Nonec	CsJtj�dddd�}tj�ddddd�|j��}|�|jj|dd�|�dS)	N�foo�bar�bazzqux.py�__pycache__z
qux.{}.pycrs)�optimization)�osr�r�format�tagr	r�cache_from_source)rr�rqr
r
r�test_cache_from_source0s
z#PEP3147Tests.test_cache_from_sourcec
CsBt�tjdd��(|�t��|j�d�WdQRXWdQRXdS)N�	cache_tagzwhatever.py)r�	swap_attrrW�implementationr�NotImplementedErrorrr�)rr
r
r�#test_cache_from_source_no_cache_tag;sz0PEP3147Tests.test_cache_from_source_no_cache_tagcCsBtj�dd�}tj�ddd�|j��}|�|jj|dd�|�dS)Nzfoo.bar�filer�z
file{}.pycrs)r�)r�r�rr�r�r	rr�)rr�rqr
r
r�test_cache_from_source_no_dotAs

z*PEP3147Tests.test_cache_from_source_no_dotc
Cs�tj�dddd�}t���Tt�d�|�|j�|d�|jj|dd��|�|j�|d	�|jj|d
d��WdQRXt���Xt�d�|�	t
��|j�|d�WdQRX|�	t
��|j�|d	�WdQRXWdQRXdS)Nr�r�r�zqux.pyrDFr)r�TrsrL)r�r�rrErFrGr	rr�rrH)rr�r
r
r�%test_cache_from_source_debug_overrideIs



z2PEP3147Tests.test_cache_from_source_debug_overridecCs6d}tj�dd�|j��}|�|jj|dd�|�dS)Nzfoo.pyr�z
foo.{}.pycrs)r�)r�r�rr�r�r	rr�)rr�rqr
r
r�test_cache_from_source_cwdZsz'PEP3147Tests.test_cache_from_source_cwdc
Cs�tj�ddd�}Gdd�d�}t���|t�d�|�|j�|g�|jj|dd��|�|j�|d	g�|jj|d
d��|�	t
��|j�d|��WdQRXWdQRXdS)Nr�r�zbaz.pyc@seZdZdd�ZdS)z=PEP3147Tests.test_cache_from_source_override.<locals>.BearishcSst�dS)N)�RuntimeError)rr
r
rrcgrOzFPEP3147Tests.test_cache_from_source_override.<locals>.Bearish.__bool__N)rrrrcr
r
r
r�Bearishfsr�rDr)r��rsz/foo/bar/baz.py)r�r�rrErFrGr	rr�rr�)rr�r�r
r
r�test_cache_from_source_override`s

z,PEP3147Tests.test_cache_from_source_overridecCs6d}tj�dd�|j��}|�|jj|dd�|�dS)Nzfoo.pyr�z
foo.{}.pycrs)r�)r�r�rr�r�r	rr�)rr�rqr
r
r�0test_cache_from_source_optimization_empty_stringrsz=PEP3147Tests.test_cache_from_source_optimization_empty_stringcCs|d}tjj}tj�dd�|j��}|dkr4|d}n,|dkrL|d�|�}nd�|�}|�|�|�	|j
j|dd	�|�dS)
Nzfoo.pyr�zfoo.{}rz.pyc�z.opt-{}.pycz){!r} is a non-standard optimization level)r�)rW�flags�optimizer�r�rr�r�ZskipTestr	rr�)rr�Zoptimization_level�
almost_expectrq�msgr
r
r�(test_cache_from_source_optimization_Noneys


z5PEP3147Tests.test_cache_from_source_optimization_Nonec	Cs�d}tjtj}tj�dd�|j��}|jj	||d�}|�
||d�|��|�
|jj	|dd�|d�|�t��|jj	|dd�WdQRXdS)	Nzfoo.pyr�zfoo.{})r�z.opt-{}.pycr\z.opt-42.pyczpath/is/bad)
�stringZ
ascii_letters�digitsr�r�rr�r�rr�r	rr�)rr�Zvalid_charactersr�Zgotr
r
r�'test_cache_from_source_optimization_set�s
z4PEP3147Tests.test_cache_from_source_optimization_setc
CsJt���8t�d�|�t��|jjdddd�WdQRXWdQRXdS)NrDzfoo.pyFrs)r�)rErFrGr�	TypeErrorrr�)rr
r
r�;test_cache_from_source_debug_override_optimization_both_set�s

zHPEP3147Tests.test_cache_from_source_debug_override_optimization_both_set�\�/z/test meaningful only where os.altsep is definedcCs$|�|jjddd�d�|j��dS)Nz\foo\bar\baz/qux.pyrs)r�z#\foo\bar\baz\__pycache__\qux.{}.pyc)r	rr�r�r�)rr
r
r�)test_sep_altsep_and_sep_cache_from_source�sz6PEP3147Tests.test_sep_altsep_and_sep_cache_from_sourcec	CsHt�dddd�}tj�ddddd�|j��}|�|jj	|dd�|�dS)	Nr�r�r�zqux.pyr�z
qux.{}.pycrs)r�)
�pathlib�PurePathr�r�rr�r�r	rr�)rr�rqr
r
r�$test_source_from_cache_path_like_arg�s
z1PEP3147Tests.test_source_from_cache_path_like_argz4requires sys.implementation.cache_tag to not be Nonec	CsFtj�ddddd�|j��}tj�dddd�}|�|j�|�|�dS)Nr�r�r�r�z
qux.{}.pyczqux.py)r�r�rr�r�r	r�source_from_cache)rr�rqr
r
r�test_source_from_cache�sz#PEP3147Tests.test_source_from_cachec
CsRtj�ddd�}t�tjdd��(|�t��|j	�
|�WdQRXWdQRXdS)Nrr�zwhatever.pycr�)r�r�rrr�rWr�rr�rr�)rr�r
r
r�#test_source_from_cache_no_cache_tag�sz0PEP3147Tests.test_source_from_cache_no_cache_tagcCs|�t|jjd�dS)Nz/foo/bar/bazqux.pyc)rr�rr�)rr
r
r�test_source_from_cache_bad_path�sz,PEP3147Tests.test_source_from_cache_bad_pathcCs|�t|jjd�dS)Nzfoo.cpython-32.pyc)rr�rr�)rr
r
r�test_source_from_cache_no_slash�sz,PEP3147Tests.test_source_from_cache_no_slashcCs|�t|jjd�dS)Nz__pycache__/foo.pyc)rr�rr�)rr
r
r�#test_source_from_cache_too_few_dots�sz0PEP3147Tests.test_source_from_cache_too_few_dotsc	Cs&|�t��|j�d�WdQRXdS)Nz(__pycache__/foo.cpython-32.opt-1.foo.pyc)rr�rr�)rr
r
r�$test_source_from_cache_too_many_dots�sz1PEP3147Tests.test_source_from_cache_too_many_dotscCs|�t|jjd�dS)Nz"__pycache__/foo.cpython-32.foo.pyc)rr�rr�)rr
r
r�test_source_from_cache_not_opt�sz+PEP3147Tests.test_source_from_cache_not_optcCs|�t|jjd�dS)Nz/foo/bar/foo.cpython-32.foo.pyc)rr�rr�)rr
r
r�$test_source_from_cache_no__pycache__�sz1PEP3147Tests.test_source_from_cache_no__pycache__cCs.tj�dd�|j��}|�|j�|�d�dS)Nr�zfoo.{}.opt-1.pyczfoo.py)r�r�rr�r�r	rr�)rr�r
r
r�)test_source_from_cache_optimized_bytecode�sz6PEP3147Tests.test_source_from_cache_optimized_bytecodec	Cs<tj�dd�|j��}|�t��|j�|�WdQRXdS)Nr�zfoo.{}.opt-.pyc)	r�r�rr�r�rr�rr�)rr�r
r
r�+test_source_from_cache_missing_optimization�sz8PEP3147Tests.test_source_from_cache_missing_optimizationc	CsDt�ddddd�|j��}tj�dddd�}|�|j�	|�|�dS)Nr�r�r�r�z
qux.{}.pyczqux.py)
r�r�r�r�r�r�rr	rr�)rr�rqr
r
rr��s)#rrrrkrWr�r�r��unittest�
skipUnlessr�r�r�r�r�r�r�r�r�r�r��sep�altsepr�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr�*s<

r�c@s,eZdZdZe�ejjdkd�dd��Z	dS)r�zA
    Test release compatibility issues relating to importlib
    )�	candidate�finalz8only applies to candidate or final python release levelscCs2d}t�tjjdd�d�}d}|�|||�dS)a
        Each python minor release should generally have a MAGIC_NUMBER
        that does not change once the release reaches candidate status.

        Once a release reaches candidate status, the value of the constant
        EXPECTED_MAGIC_NUMBER in this test should be changed.
        This test will then check that the actual MAGIC_NUMBER matches
        the expected value for the release.

        In exceptional cases, it may be required to change the MAGIC_NUMBER
        for a maintenance release. In this case the change should be
        discussed in python-dev. If a change is required, community
        stakeholders such as OS package maintainers must be notified
        in advance. Such exceptional releases will then require an
        adjustment to this test case.
        iB
Nr��littlea�To avoid breaking backwards compatibility with cached bytecode files that can't be automatically regenerated by the current user, candidate and final releases require the current  importlib.util.MAGIC_NUMBER to match the expected magic number in this test. Set the expected magic number in this test to the current MAGIC_NUMBER to continue with the release.

Changing the MAGIC_NUMBER for a maintenance release requires discussion in python-dev and notification of community stakeholders.)�int�
from_bytesrrr�r	)rZEXPECTED_MAGIC_NUMBER�actualr�r
r
r�test_magic_numbersz"MagicNumberTests.test_magic_numberN)
rrrrkr�r�rW�version_info�releaselevelr�r
r
r
rr��s
�__main__)1rsrZimport_importlibr%r�rZimportlib_util�importlib.utilrr�r�r�rWrrr'r�rErZ	test_bothZFrozen_DecodeSourceBytesTestsZSource_DecodeSourceBytesTestsrZFrozen_ModuleFromSpecTestsZSource_ModuleFromSpecTestsrCZFrozen_ModuleForLoaderTestsZSource_ModuleForLoaderTestsrmZFrozen_SetPackageTestsZSource_SetPackageTestsr{ZFrozen_SetLoaderTestsZSource_SetLoaderTestsr�ZFrozen_ResolveNameTestsZSource_ResolveNameTestsr�ZFrozen_FindSpecTestsZSource_FindSpecTestsr�ZFrozen_MagicNumberTestsZSource_MagicNumberTestsr�ZFrozen_PEP3147TestsZSource_PEP3147TestsZTestCaser�mainr
r
r
r�<module>sN



J
<,#

S+