403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.153
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/test_importlib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/test_importlib/__pycache__/test_util.cpython-36.pyc
3

�w2_�z�@s�ddlmZejd�Zejd�Zejd�Zejd�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�ej0�dS)�)�utilz
importlib.abc�	importlibzimportlib.machineryzimportlib.util�N)�supportc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�DecodeSourceBytesTestsustring ='ü'cCs&|jjd�}|j|jj|�|j�dS)Nzutf-8)�source�encode�assertEqualr�
decode_source)�self�source_bytes�r
�B/opt/alt/python36/lib64/python3.6/test/test_importlib/test_util.py�test_ut8_defaultsz'DecodeSourceBytesTests.test_ut8_defaultcCs>d|j}|jd�}||jd�ks&t�|j|jj|�|�dS)Nz# coding=latin-1
zlatin-1zutf-8)rr�AssertionErrorr	rr
)rrrr
r
r�test_specified_encodings

z.DecodeSourceBytesTests.test_specified_encodingcCsBdj|j|jg�}|jd�}|j|jj|�dj|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�}|jjd|��}|jt��|jj|�}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�}|jjd|��}|jj|�}|j|tj�|j	|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�}|jjd|��}|jj|�}|j|��|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|jjdt��}|jj|�}|j|j|j�dS)Nr)rr�objectrr!r	rr))rr"rr
r
r�
test___name__Msz!ModuleFromSpecTests.test___name__cCs.|jjdt��}|jj|�}|j|j|�dS)Nr)rrr-rr!r	�__spec__)rr"rr
r
r�
test___spec__Rsz!ModuleFromSpecTests.test___spec__cCs2t�}|jjd|�}|jj|�}|j|j|�dS)Nr)r-rrrr!�assertIs�
__loader__)r�loaderr"rr
r
r�test___loader__Wsz#ModuleFromSpecTests.test___loader__cCs0|jjdt��}|jj|�}|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�}|jj|�}|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|_|jj|�}|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<|jjdt��}d|_d|_|jj|�}|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,tj��tjdt�|jj|�SQRXdS)N�ignore)�warnings�catch_warnings�simplefilter�DeprecationWarningr�module_for_loader)�cls�funcr
r
rrI~s
z&ModuleForLoaderTests.module_for_loadercCsJtj��8tjdt�|jt��|jjdd��}WdQRXWdQRXdS)N�errorcSs|S)Nr
)�xr
r
r�<lambda>�sz3ModuleForLoaderTests.test_warning.<locals>.<lambda>)rErFrGrHrrrI)rrKr
r
r�test_warning�s
z!ModuleForLoaderTests.test_warningcCs|jdd��}|||�S)NcSs|S)Nr
)rrr
r
rrN�sz4ModuleForLoaderTests.return_module.<locals>.<lambda>)rI)rr)�fxnr
r
r�
return_module�sz"ModuleForLoaderTests.return_modulecCs:dd�}|j|�}y|||�Wntk
r4YnXdS)NcSst�dS)N)r )rrr
r
r�to_wrap�sz5ModuleForLoaderTests.raise_exception.<locals>.to_wrap)rIr )rr)rRrPr
r
r�raise_exception�s
z$ModuleForLoaderTests.raise_exceptionc
CsRd}tj|��|j|�}|j|tj�WdQRX|j|tj�|j	|j
|�dS)Nza.b.c)r�uncacherQ�assertIn�sys�modulesr&r'r(r	r)rZmodule_namerr
r
r�test_new_module�s
z$ModuleForLoaderTests.test_new_modulecs�G�fdd�d�}d}tjd�}d|_d|_tj|��N|tj|<|�}|j|�}�j	|tj|��j
|j|��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)rrrr8rIrYr
)rr
r�
FakeLoader�srZza.b.c�*)r'r(r2r5rrTrVrWrYr1r	)rrZr)rr3Zreturned_moduler
)rr�test_reload�s


z ModuleForLoaderTests.test_reloadc
Cs6d}tj|��|j|�|j|tj�WdQRXdS)Nza.b.c)rrTrS�assertNotInrVrW)rr)r
r
r�test_new_module_failure�s
z,ModuleForLoaderTests.test_new_module_failurecCsNd}tj|�}tj|��,|tj|<|j|�|j|tj|�WdQRXdS)Nza.b.c)r'r(rrTrVrWrSr1)rr)rr
r
r�test_reload_failure�s


z(ModuleForLoaderTests.test_reload_failurecCs6dd�}|j|�}|j|j|j�|j|j|j�dS)NcSsdS)Nr
)rrr
r
rrP�sz6ModuleForLoaderTests.test_decorator_attrs.<locals>.fxn)rIr	rr)rrP�wrappedr
r
r�test_decorator_attrs�s
z)ModuleForLoaderTests.test_decorator_attrsc
CsbGdd�dtj�}d}||�}tj|��0|j|�|tj|<|j|�}|j||�WdQRXdS)Nc@seZdZdd�ZdS)z;ModuleForLoaderTests.test_false_module.<locals>.FalseModulecSsdS)NFr
)rr
r
r�__bool__�szDModuleForLoaderTests.test_false_module.<locals>.FalseModule.__bool__N)rrrrbr
r
r
r�FalseModule�src�mod)	r'r(rrTZassertFalserVrWrQr1)rrcr)rZgivenr
r
r�test_false_module�s


z&ModuleForLoaderTests.test_false_modulecs�G�fdd�d�}d}tj|��B|d�}|j|�}�j|j|��j|j|��j|jd�WdQRXd}tj|��B|d�}|j|�}�j|j|��j|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)rf)rr)r
r
rr8�szGModuleForLoaderTests.test_attributes_set.<locals>.FakeLoader.is_packagecSs|S)Nr
)rrr
r
rrY�szHModuleForLoaderTests.test_attributes_set.<locals>.FakeLoader.load_moduleN)rrrrgr8rIrYr
)rr
rrZ�srZzpkg.modF�pkgzpkg.subT)rrTrYr	rr1r2r5)rrZr)r3rr
)rr�test_attributes_set�s	

z(ModuleForLoaderTests.test_attributes_setN)rrr�__doc__�classmethodrIrOrQrSrXr\r^r_rarerir
r
r
rrCzs	
	rCc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�SetPackageTestsz%Tests for importlib.util.set_package.cs`�fdd�}|jj|�}tj��tjdt�|�WdQRX|jt�d��|j|�j	�dS)zcVerify the module has the expected value for __package__ after
        passing through set_package.cs�S)Nr
r
)rr
rrNsz(SetPackageTests.verify.<locals>.<lambda>rDNr5)
r�set_packagerErFrGrH�
assertTrue�hasattrr	r5)rr�expectrPr`r
)rr�verifys
zSetPackageTests.verifycCs tjd�}d|_|j|d�dS)Nr�)r'r(r5rq)rrr
r
r�test_top_levels
zSetPackageTests.test_top_levelcCs(tjd�}dg|_d|_|j|d�dS)Nrhz<path>)r'r(r9r5rq)rrr
r
r�test_packages
zSetPackageTests.test_packagecCs tjd�}d|_|j|d�dS)Nzpkg.modrh)r'r(r5rq)rrr
r
r�test_submodules
zSetPackageTests.test_submodulecCs.tjd�}t|d�rt|d�|j|d�dS)Nrdr5rr)r'r(ro�delattrrq)rrr
r
r�test_setting_if_missing s


z'SetPackageTests.test_setting_if_missingcCs.x(dD] }tjd�}||_|j||�qWdS)NTFrd)TF)r'r(r5rq)r�valuerr
r
r�test_leaving_alone's

z"SetPackageTests.test_leaving_alonec
CsXdd�}tj��tjdt�|jj|�}WdQRX|j|j|j�|j|j|j�dS)NcSsdS)Nr
)rr
r
rrP/sz1SetPackageTests.test_decorator_attrs.<locals>.fxnrD)	rErFrGrHrrmr	rr)rrPr`r
r
rra.s
z$SetPackageTests.test_decorator_attrsN)rrrrjrqrsrtrurwryrar
r
r
rrl�srlc@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
rrYDsz;SetLoaderTests.DummyLoader.<locals>.DummyLoader.load_moduleN)rrrr�
set_loaderrYr
)rr
r�DummyLoaderCsr|)�	__class__r|)rr|r
)rrr|@szSetLoaderTests.DummyLoadercCsl|j�}tjd�|_y
|j`Wntk
r2YnXtj��&tjdt	�|j
||jd�j�WdQRXdS)N�blahrD)r|r'r(rr2�AttributeErrorrErFrGrHr	rY)rr3r
r
r�test_no_attributeJs

z SetLoaderTests.test_no_attributecCsT|j�}tjd�|_d|j_tj��&tjdt�|j	||j
d�j�WdQRXdS)Nr~rD)r|r'r(rr2rErFrGrHr	rY)rr3r
r
r�test_attribute_is_NoneUs
z%SetLoaderTests.test_attribute_is_NonecCsT|j�}tjd�|_d|j_tj��&tjdt�|j	d|j
d�j�WdQRXdS)Nr~r[rD)r|r'r(rr2rErFrGrHr	rY)rr3r
r
r�test_not_reset]s
zSetLoaderTests.test_not_resetN)	rrrrj�propertyr|r�r�r�r
r
r
rrz<s

rzc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�ResolveNameTestsz$Tests importlib.util.resolve_name().cCs|jd|jjdd��dS)N�bacon)r	r�resolve_name)rr
r
r�
test_absoluteoszResolveNameTests.test_absolutecCs|jd|jjdd��dS)Nr��spam)r	rr�)rr
r
r�test_absolute_within_packagessz-ResolveNameTests.test_absolute_within_packagec
Cs(|jt��|jjdd�WdQRXdS)Nz.baconrr)r�
ValueErrorrr�)rr
r
r�test_no_packagewsz ResolveNameTests.test_no_packagecCs|jd|jjdd��dS)Nzspam.eggs.baconz.baconz	spam.eggs)r	rr�)rr
r
r�test_in_package|sz ResolveNameTests.test_in_packagecCs|jd|jjdd��dS)Nz
spam.baconz..baconz	spam.eggs)r	rr�)rr
r
r�test_other_package�sz#ResolveNameTests.test_other_packagec
Cs(|jt��|jjdd�WdQRXdS)Nz..baconr�)rr�rr�)rr
r
r�test_escape�szResolveNameTests.test_escapeN)
rrrrjr�r�r�r�r�r�r
r
r
rr�ksr�c@sreZdZGdd�d�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�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}tj|��Ptj|�}d}|jj||�}||_||_|tj	|<|jj
|�}|j||�WdQRXdS)N�some_modz	a loader!)rrTr'r(rrr2r/rVrWr�r	)rr)rr3r"�foundr
r
r�test_sys_modules�s

zFindSpecTests.test_sys_modulesc
Csfd}tj|��Ntj|�}|`d}|jj||�}||_|tj	|<|jj
|�}|j||�WdQRXdS)Nr�z	a loader!)rrTr'r(r2rrr/rVrWr�r	)rr)rr3r"r�r
r
r�#test_sys_modules_without___loader__�s

z1FindSpecTests.test_sys_modules_without___loader__cCsZd}tj|��Btj|�}d|_|tj|<|jt��|jj	|�WdQRXWdQRXdS)Nr�)
rrTr'r(r/rVrWrr�r�)rr)rr
r
r�test_sys_modules_spec_is_None�s

z+FindSpecTests.test_sys_modules_spec_is_Nonec
Cs^d}tj|��Ftj|�}|jj|d�}||_|tj|<|jj	|�}|j
||�WdQRXdS)Nr�)rrTr'r(rrr/rVrWr�r	)rr)rr"r�r
r
r�test_sys_modules_loader_is_None�s

z-FindSpecTests.test_sys_modules_loader_is_NonecCsrd}tj|��Ztj|�}y|`Wntk
r6YnX|tj|<|jt	��|jj
|�WdQRXWdQRXdS)Nr�)rrTr'r(r/rrVrWrr�r�)rr)rr
r
r� test_sys_modules_spec_is_not_set�s

z.FindSpecTests.test_sys_modules_spec_is_not_setcCsTd}tj|��<tj|jgd�� |j|ddf|jj|��WdQRXWdQRXdS)Nr�)�	meta_path)rrTZimport_stater�r	r�)rr)r
r
r�test_success�s
zFindSpecTests.test_successcCs|j|jjd��dS)NZnevergoingtofindthismodule)ZassertIsNonerr�)rr
r
r�test_nothing�szFindSpecTests.test_nothingcCs�d}d}tj|dd��l}tj|||�\}}|jj|�}|j|d�|j|ttj��|j	|ttj��|jj|�}|j
||�WdQRXdS)Nr��hamT)rh)r�temp_module�	submoduler��assertIsNotrU�sortedrVrWr]r	)rr)�subname�pkg_dir�fullname�_r"�
spec_againr
r
r�test_find_submodule�sz!FindSpecTests.test_find_submodulecCs�d}d}tj|dd��x}|jj|�tj|||�\}}|jj|�}|j|d�|j|tt	j
��|j|tt	j
��|jj|�}|j||�WdQRXdS)Nr�r�T)rh)
rr��init�
import_moduler�r�r�rUr�rVrWr]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}tj|||�\}}d|}|jj||�}|j|d�|j|ttj��|j	|ttj��|jj|�}|j
||�WdQRXdS)Nr�r�T)rh�.)rr�r�r�r�rUr�rVrWr]r	)	rr)r�r�r�r��relnamer"r�r
r
r�test_find_relative_module�sz'FindSpecTests.test_find_relative_modulecCs�d}d}tj|dd��f}tj|||�\}}d|}|jt��|jj|�WdQRX|j|ttj	��|j|ttj	��WdQRXdS)Nr�r�T)rhr�)
rr�r�rr�r�r]r�rVrW)rr)r�r�r�r�r�r
r
r�)test_find_relative_module_missing_packagesz7FindSpecTests.test_find_relative_module_missing_packageN)rrrr�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr��s	

r�)r�rrc@seZdZdd�Zdd�ZdS)�MagicNumberTestscCs|jt|jj�d�dS)N�)r	�lenr�MAGIC_NUMBER)rr
r
r�test_lengthszMagicNumberTests.test_lengthcCs|j|jjjd��dS)Ns
)rnrr��endswith)rr
r
r�test_incorporates_rnsz%MagicNumberTests.test_incorporates_rnN)rrrr�r�r
r
r
rr�sr�c@s<eZdZdZejjZej	ejjdk	d�dd��Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zej	ejdko�ejdkd�dd��Zej	ejjdk	d�dd��Zej	ejjdk	d�d d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Z d0d1�Z!d2d3�Z"ej	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 NonecCsJtjjdddd�}tjjdddddj|j��}|j|jj|dd�|�dS)	N�foo�bar�bazzqux.py�__pycache__z
qux.{}.pycrr)�optimization)�osr�r�format�tagr	r�cache_from_source)rr�rpr
r
r�test_cache_from_source*s
z#PEP3147Tests.test_cache_from_sourcecCsBtjtjdd��(|jt��|jjd�WdQRXWdQRXdS)N�	cache_tagzwhatever.py)r�	swap_attrrV�implementationr�NotImplementedErrorrr�)rr
r
r�#test_cache_from_source_no_cache_tag5sz0PEP3147Tests.test_cache_from_source_no_cache_tagcCsBtjjdd�}tjjdddj|j��}|j|jj|dd�|�dS)Nzfoo.bar�filer�z
file{}.pycrr)r�)r�r�rr�r�r	rr�)rr�rpr
r
r�test_cache_from_source_no_dot;s

z*PEP3147Tests.test_cache_from_source_no_dotcCs�tjjdddd�}tj��Ttjd�|j|jj|d�|jj|dd��|j|jj|d	�|jj|d
d��WdQRXtj��Xtjd�|j	t
��|jj|d�WdQRX|j	t
��|jj|d	�WdQRXWdQRXdS)Nr�r�r�zqux.pyrDFr)r�TrrrL)r�r�rrErFrGr	rr�rrH)rr�r
r
r�%test_cache_from_source_debug_overrideCs



z2PEP3147Tests.test_cache_from_source_debug_overridecCs6d}tjjddj|j��}|j|jj|dd�|�dS)Nzfoo.pyr�z
foo.{}.pycrr)r�)r�r�rr�r�r	rr�)rr�rpr
r
r�test_cache_from_source_cwdTsz'PEP3147Tests.test_cache_from_source_cwdcCs�tjjddd�}Gdd�d�}tj��|tjd�|j|jj|g�|jj|dd��|j|jj|d	g�|jj|d
d��|j	t
��|jjd|��WdQRXWdQRXdS)Nr�r�zbaz.pyc@seZdZdd�ZdS)z=PEP3147Tests.test_cache_from_source_override.<locals>.BearishcSst�dS)N)�RuntimeError)rr
r
rrbaszFPEP3147Tests.test_cache_from_source_override.<locals>.Bearish.__bool__N)rrrrbr
r
r
r�Bearish`sr�rDr)r��rrz/foo/bar/baz.py)r�r�rrErFrGr	rr�rr�)rr�r�r
r
r�test_cache_from_source_overrideZs

z,PEP3147Tests.test_cache_from_source_overridecCs6d}tjjddj|j��}|j|jj|dd�|�dS)Nzfoo.pyr�z
foo.{}.pycrr)r�)r�r�rr�r�r	rr�)rr�rpr
r
r�0test_cache_from_source_optimization_empty_stringlsz=PEP3147Tests.test_cache_from_source_optimization_empty_stringcCs|d}tjj}tjjddj|j��}|dkr4|d}n,|dkrL|dj|�}ndj|�}|j|�|j	|j
j|dd	�|�dS)
Nzfoo.pyr�zfoo.{}rz.pyc�z.opt-{}.pycz){!r} is a non-standard optimization level)r�)rV�flags�optimizer�r�rr�r�ZskipTestr	rr�)rr�Zoptimization_level�
almost_expectrp�msgr
r
r�(test_cache_from_source_optimization_Noness


z5PEP3147Tests.test_cache_from_source_optimization_NonecCs�d}tjtj}tjjddj|j��}|jj	||d�}|j
||dj|��|j
|jj	|dd�|d�|jt��|jj	|dd�WdQRXdS)	Nzfoo.pyr�zfoo.{})r�z.opt-{}.pycr[z.opt-42.pyczpath/is/bad)
�stringZ
ascii_lettersZdigitsr�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_setcCsJtj��8tjd�|jt��|jjdddd�WdQRXWdQRXdS)NrDzfoo.pyFrr)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$|j|jjddd�dj|j��dS)Nz\foo\bar\baz/qux.pyrr)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_sourcecCsHtjdddd�}tjjdddddj|j��}|j|jj	|dd�|�dS)	Nr�r�r�zqux.pyr�z
qux.{}.pycrr)r�)
�pathlib�PurePathr�r�rr�r�r	rr�)rr�rpr
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 NonecCsFtjjdddddj|j��}tjjdddd�}|j|jj|�|�dS)Nr�r�r�r�z
qux.{}.pyczqux.py)r�r�rr�r�r	r�source_from_cache)rr�rpr
r
r�test_source_from_cache�sz#PEP3147Tests.test_source_from_cachecCsRtjjddd�}tjtjdd��(|jt��|j	j
|�WdQRXWdQRXdS)Nr~r�zwhatever.pycr�)r�r�rrr�rVr�rr�rr�)rr�r
r
r�#test_source_from_cache_no_cache_tag�sz0PEP3147Tests.test_source_from_cache_no_cache_tagcCs|jt|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|jt|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|jt|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&|jt��|jjd�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|jt|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|jt|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.tjjddj|j��}|j|jj|�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<tjjddj|j��}|jt��|jj|�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_optimizationcCsDtjdddddj|j��}tjjdddd�}|j|jj	|�|�dS)Nr�r�r�r�z
qux.{}.pyczqux.py)
r�r�r�r�r�r�rr	rr�)rr�rpr
r
rr��s)#rrrrjrVr�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,eZdZdZejejjdkd�dd��Z	dS)	r�zA
    Test release compatibility issues relating to importlib
    �	candidate�finalz8only applies to candidate or final python release levelscCs2d}tjtjjdd�d�}d}|j|||�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.
        i3
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_NUMBERZactualr�r
r
r�test_magic_number�sz"MagicNumberTests.test_magic_numberN)r�r�)
rrrrjr�r�rV�version_info�releaselevelr�r
r
r
rr��s
�__main__)1rrrZimport_importlibr%r�rZimportlib_util�importlib.utilrr�r�r�rVrrr'r�rErZ	test_bothZFrozen_DecodeSourceBytesTestsZSource_DecodeSourceBytesTestsrZFrozen_ModuleFromSpecTestsZSource_ModuleFromSpecTestsrCZFrozen_ModuleForLoaderTestsZSource_ModuleForLoaderTestsrlZFrozen_SetPackageTestsZSource_SetPackageTestsrzZFrozen_SetLoaderTestsZSource_SetLoaderTestsr�ZFrozen_ResolveNameTestsZSource_ResolveNameTestsr�ZFrozen_FindSpecTestsZSource_FindSpecTestsr�ZFrozen_MagicNumberTestsZSource_MagicNumberTestsr�ZFrozen_PEP3147TestsZSource_PEP3147TestsZTestCaser�mainr
r
r
r�<module>sL



J
<,#

S+


Youez - 2016 - github.com/yon3zu
LinuXploit