Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib64/python3.6/test/test_importlib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/test/test_importlib/__pycache__/test_abc.cpython-36.opt-1.pyc

3

� f�}�@s�ddlZddlZddlZddlZddlZddlZddlmZddlZddl	Z	ddl	m
Z
ddlZddlm
Zejd�Zejd�Zejd�Zejd	�Z
Gd
d�d�ZGdd
�d
e�Zejeed�\ZZGdd�de�Zejeed�\ZZGdd�de�Zejeed�\ZZGdd�de�Zejeed�\ZZ Gdd�de�Z!eje!ed�\Z"Z#Gdd�de�Z$eje$ed�\Z%Z&Gdd�de�Z'eje'ed�\Z(Z)dWdd�Z*Gdd�d�Z+Gd d
�d
�ZGd!d"�d"e+�Z,eje,�\Z-Z.Gd#d�d�ZGd$d%�d%e+�Z/eje/�\Z0Z1Gd&d'�d'�Z2Gd(d)�d)e+�Z3eje3�\Z4Z5Gd*d�de2�ZGd+d,�d,e+�Z6eje6�\Z7Z8Gd-d�de2�Ze*e�Z9Gd.d/�d/e+�Z:eje:�\Z;Z<Gd0d�de�Z!e*e!�Z=Gd1d2�d2e+�Z>eje:�\Z?Z@Gd3d4�d4�ZAejeAee
d5�\ZBZCGd6d7�d7�ZDejeDee
ed8�\ZEZFGd9d:�d:�ZGejeGee
d5�\ZHZIGd;d<�d<�ZJejeJe9d=�\ZKZLGd>d?�d?�ZMejeMe9d=�\ZNZOGd@dA�dA�ZPejePe9ee
dB�\ZQZRGdCdD�dD�ZSejeSe=dE�\ZTZUGdFdG�dG�ZVe*eVd�ZWGdHd�deV�Z'e*e'e
edI�ZXGdJdK�dK�ZYGdLdM�dMeY�ZZejeZe
eWdN�\Z[Z\e	j]ej^dO�GdPdQ�dQeY��Z_eje_ee
eXdR�\Z`ZaGdSdT�dT�ZbejebeWdU�\ZcZdeedVk�r�e	jf�dS)X�N)�support)�mock�)�util�	importlibz
importlib.abczimportlib.machineryzimportlib.utilc@s0eZdZdZgZgZdd�Zdd�Zdd�ZdS)	�InheritanceTestszSTest that the specified class is a subclass/superclass of the expected
    classes.csR�fdd��jD��_t�d�r>�jj��fdd��jD��_t�j�j��_	dS)Ncsg|]}t�j|��qS�)�getattr�abc)�.0�
class_name)�selfr�A/opt/alt/python36/lib64/python3.6/test/test_importlib/test_abc.py�
<listcomp>sz*InheritanceTests.setUp.<locals>.<listcomp>�subclass_namescsg|]}t�|��qSr)r	)rr)�	machineryrrr(s)
�superclass_names�superclasses�hasattrr
rr�
subclassesr	Z_NAME�_InheritanceTests__test)r
r)rr
r�setUps


zInheritanceTests.setUpcCs2x,|jD]"}|jt||j�dj||j��qWdS)Nz{0} is not a subclass of {1})r�
assertTrue�
issubclassr�format)r
�subclassrrr�test_subclasses-sz InheritanceTests.test_subclassescCs2x,|jD]"}|jt|j|�dj||j��qWdS)Nz{0} is not a superclass of {1})rrrrr)r
Z
superclassrrr�test_superclasses3sz"InheritanceTests.test_superclassesN)	�__name__�
__module__�__qualname__�__doc__rrrrrrrrrrsrc@seZdZdgZddddgZdS)�MetaPathFinder�Finder�BuiltinImporter�FrozenImporter�
PathFinder�WindowsRegistryFinderN)rrr rrrrrrr":sr")r
c@seZdZdgZdgZdS)�PathEntryFinderr#�
FileFinderN)rrr rrrrrrr(Esr(c@seZdZdgZdS)�ResourceLoader�LoaderN)rrr rrrrrr*Osr*c@seZdZdgZdddgZdS)�
InspectLoaderr+r$r%�ExtensionFileLoaderN)rrr rrrrrrr,Xsr,c@seZdZdgZdgZdS)�ExecutionLoaderr,r-N)rrr rrrrrrr.bsr.c@seZdZddgZddgZdS)�
FileLoaderr*r.�SourceFileLoader�SourcelessFileLoaderN)rrr rrrrrrr/lsr/c@seZdZddgZdgZdS)�SourceLoaderr*r.r0N)rrr rrrrrrr2vsr2FcsB�dkr|j��fdd�tj�D�}�fdd�tj||f|�D�S)Ncsi|]\}}t|��|�qSr)r	)rZkindZsplitabc)�namerr�
<dictcomp>�sz'make_abc_subclasses.<locals>.<dictcomp>csi|]}�r|�n||j�qSr)�_KIND)r�cls)�instrrr4�s)rr
�items�	test_utilZsplit_frozen)Z
base_classr3r7�kwargs�baser)r7r3r�make_abc_subclasses�s

r<c@seZdZedd��ZdS)�ABCTestHarnesscCs|j|j}|�}||j_|S)N)�SPLITr5�	__class__�ins)r
r6r@rrrr@�szABCTestHarness.insN)rrr �propertyr@rrrrr=�sr=cseZdZ�fdd�Z�ZS)r"cst�j||�S)N)�super�find_module)r
�fullname�path)r?rrrC�szMetaPathFinder.find_module)rrr rC�
__classcell__rr)r?rr"�sc@s$eZdZee�Zdd�Zdd�ZdS)�MetaPathFinderDefaultsTestscCs|j|jjdd��dS)N�	something)�assertIsNoner@rC)r
rrr�test_find_module�sz,MetaPathFinderDefaultsTests.test_find_modulecCs|jj�dS)N)r@�invalidate_caches)r
rrr�test_invalidate_caches�sz2MetaPathFinderDefaultsTests.test_invalidate_cachesN)rrr r<r"r>rJrLrrrrrG�srGcseZdZ�fdd�Z�ZS)r(cst�j|�S)N)rB�find_loader)r
rD)r?rrrM�szPathEntryFinder.find_loader)rrr rMrFrr)r?rr(�sc@s,eZdZee�Zdd�Zdd�Zdd�ZdS)�PathEntryFinderDefaultsTestscCs|jdgf|jjd��dS)NrH)�assertEqualr@rM)r
rrr�test_find_loader�sz-PathEntryFinderDefaultsTests.test_find_loadercCs|jd|jjd��dS)NrH)rOr@rC)r
rrrrC�sz(PathEntryFinderDefaultsTests.find_modulecCs|jj�dS)N)r@rK)r
rrrrL�sz3PathEntryFinderDefaultsTests.test_invalidate_cachesN)	rrr r<r(r>rPrCrLrrrrrN�srNcseZdZ�fdd�Z�ZS)r+cst�j|�S)N)rB�load_module)r
rD)r?rrrQ�szLoader.load_module)rrr rQrFrr)r?rr+�sr+c@s,eZdZee�Zdd�Zdd�Zdd�ZdS)�LoaderDefaultsTestscCsd}|j|jj|��dS)Nza spec)rIr@�
create_module)r
�specrrr�test_create_module�sz&LoaderDefaultsTests.test_create_modulec	Cs&|jt��|jjd�WdQRXdS)NrH)�assertRaises�ImportErrorr@rQ)r
rrr�test_load_module�sz$LoaderDefaultsTests.test_load_modulec
CsNtjd�}|jt��|jj|�WdQRXt|�}|j|_|jt|��dS)N�blah)	�types�
ModuleTyperV�NotImplementedErrorr@�module_repr�repr�
__loader__r)r
�modZ
original_reprrrr�test_module_repr�s
z$LoaderDefaultsTests.test_module_reprN)	rrr r<r+r>rUrXrarrrrrR�srRcseZdZ�fdd�Z�ZS)r*cst�j|�S)N)rB�get_data)r
rE)r?rrrb�szResourceLoader.get_data)rrr rbrFrr)r?rr*�sc@seZdZee�Zdd�ZdS)�ResourceLoaderDefaultsTestsc	Cs&|jt��|jjd�WdQRXdS)Nz
/some/path)rV�IOErrorr@rb)r
rrr�
test_get_data�sz)ResourceLoaderDefaultsTests.test_get_dataN)rrr r<r*r>rerrrrrc�srccs(eZdZ�fdd�Z�fdd�Z�ZS)r,cst�j|�S)N)rB�
is_package)r
rD)r?rrrf�szInspectLoader.is_packagecst�j|�S)N)rB�
get_source)r
rD)r?rrrgszInspectLoader.get_source)rrr rfrgrFrr)r?rr,�sc@s eZdZeZdd�Zdd�ZdS)�InspectLoaderDefaultsTestsc	Cs&|jt��|jjd�WdQRXdS)NrY)rVrWr@rf)r
rrr�test_is_package
sz*InspectLoaderDefaultsTests.test_is_packagec	Cs&|jt��|jjd�WdQRXdS)NrY)rVrWr@rg)r
rrr�test_get_sourcesz*InspectLoaderDefaultsTests.test_get_sourceN)rrr �SPLIT_ILr>rirjrrrrrh	srhcseZdZ�fdd�Z�ZS)r.cst�j|�S)N)rB�get_filename)r
rD)r?rrrlszExecutionLoader.get_filename)rrr rlrFrr)r?rr.sc@seZdZeZdd�ZdS)�ExecutionLoaderDefaultsTestsc	Cs&|jt��|jjd�WdQRXdS)NrY)rVrWr@rl)r
rrr�test_get_filename(sz.ExecutionLoaderDefaultsTests.test_get_filenameN)rrr �SPLIT_ELr>rnrrrrrm$srmc@s(eZdZedd��Zdd�Zdd�ZdS)�MetaPathFinderFindModuleTestscsG�fdd�d|jj�}|�S)NcseZdZd�fdd�	ZdS)z@MetaPathFinderFindModuleTests.finder.<locals>.MetaPathSpecFinderNcs||f|_�S)N)�
called_for)r
rDrE�target)rTrr�	find_spec9s
zJMetaPathFinderFindModuleTests.finder.<locals>.MetaPathSpecFinder.find_spec)N)rrr rsr)rTrr�MetaPathSpecFinder7srt)r
r")r6rTrtr)rTr�finder5sz$MetaPathFinderFindModuleTests.findercCsV|jd�}dddg}d}|j||�}|j|�|j||jd�|j||jd�dS)N�a�b�crYrr)rurCrIrOrq)r
rurEr3�foundrrr�test_no_spec?s


z*MetaPathFinderFindModuleTests.test_no_speccCs<t�}|jjd|�}|j|�}|jdd�}|j||j�dS)NrY)�objectr�spec_from_loaderrurC�assertIs�loader)r
r~rTruryrrr�	test_specHs

z'MetaPathFinderFindModuleTests.test_specN)rrr �classmethodrurzrrrrrrp3s
	rp)r
rc@s0eZdZedd��Zdd�Zdd�Zdd�Zd	S)
�PathEntryFinderFindLoaderTestscsG�fdd�d|jj�}|�S)NcseZdZd�fdd�	ZdS)zBPathEntryFinderFindLoaderTests.finder.<locals>.PathEntrySpecFinderNcs
||_�S)N)rq)r
rDrr)rTrrrs\szLPathEntryFinderFindLoaderTests.finder.<locals>.PathEntrySpecFinder.find_spec)N)rrr rsr)rTrr�PathEntrySpecFinderZsr�)r
r()r6rTr�r)rTrruXsz%PathEntryFinderFindLoaderTests.findercCsH|jd�}d}|j|�}|j|d�|jg|d�|j||j�dS)NrYrr)rurMrIrOrq)r
rur3ryrrrrzbs

z+PathEntryFinderFindLoaderTests.test_no_speccCs>t�}|jjd|�}|j|�}|jd�}|j|d|j�dS)NrYr)r{rr|rurMr}r~)r
r~rTruryrrr�test_spec_with_loaderjs


z4PathEntryFinderFindLoaderTests.test_spec_with_loadercCsT|jjdd�}dddg}||_|j|�}|jd�}|j|d�|j||d�dS)NrYrvrwrxrr)r�
ModuleSpec�submodule_search_locationsrurMrIrO)r
rT�pathsruryrrr�test_spec_with_portionsqs


z6PathEntryFinderFindLoaderTests.test_spec_with_portionsN)rrr r�rurzr�r�rrrrr�Vs
r�)r
rrc@s$eZdZdd�Zdd�Zdd�ZdS)�LoaderLoadModuleTestscCsGdd�d|jj�}|�S)Nc@s eZdZdZdd�Zdd�ZdS)z0LoaderLoadModuleTests.loader.<locals>.SpecLoaderNcSs
||_dS)N)ry)r
�modulerrr�exec_module�sz<LoaderLoadModuleTests.loader.<locals>.SpecLoader.exec_modulecSsdS)z.Force some non-default module state to be set.Tr)r
rDrrrrf�sz;LoaderLoadModuleTests.loader.<locals>.SpecLoader.is_package)rrr ryr�rfrrrr�
SpecLoader�sr�)r
r+)r
r�rrrr~�s	zLoaderLoadModuleTests.loaderc
Cs�|j�}d}tj|��(|j|�|j}|jtj||�WdQRX|j||j	�|j||j
j�|j||j�|j||j
j�|j
|j�|j
|j|j
j�dS)NrY)r~r9�uncacherQryr}�sys�modulesrOr_�__spec__rr3ZassertIsNotNone�__path__r�)r
r~r3r�rrr�
test_fresh�s
z LoaderLoadModuleTests.test_freshcCs�d}|j�}tj|�}|jj||�|_||_tj|��D|t	j
|<|j|�|j}|j
|t	j
|�|j
|t	j
|�WdQRXdS)NrY)r~rZr[rr|r�r_r9r�r�r�rQryr})r
r3r~r�ryrrr�test_reload�s


z!LoaderLoadModuleTests.test_reloadN)rrr r~r�r�rrrrr��sr�c@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�InspectLoaderSourceToCodeTestsNcCsBtjd�}|j�}|dkr&|j|�}n|j||�}t||j�|S)z!Help with source_to_code() tests.rYN)rZr[�InspectLoaderSubclass�source_to_code�exec�__dict__)r
�datarEr�r~�coderrr�source_to_module�s
z/InspectLoaderSourceToCodeTests.source_to_modulecCs0d}|j|�}|jt|d��|j|jd�dS)Nz	attr = 42�attr�*)r�rrrOr�)r
�sourcer�rrr�test_source_to_code_source�s
z9InspectLoaderSourceToCodeTests.test_source_to_code_sourcecCs0d}|j|�}|jt|d��|j|jd�dS)Ns	attr = 42r�r�)r�rrrOr�)r
r�r�rrr�test_source_to_code_bytes�s
z8InspectLoaderSourceToCodeTests.test_source_to_code_bytescCs*d}|j�}|jd|�}|j|j|�dS)Nzpath/to/somewhere�)r�r�rO�co_filename)r
rEr~r�rrr�test_source_to_code_path�sz7InspectLoaderSourceToCodeTests.test_source_to_code_pathcCs$|j�}|jd�}|j|jd�dS)Nr�z<string>)r�r�rOr�)r
r~r�rrr�test_source_to_code_no_path�s
z:InspectLoaderSourceToCodeTests.test_source_to_code_no_path)N)rrr r�r�r�r�r�rrrrr��s

r�)r�c@s$eZdZdd�Zdd�Zdd�ZdS)�InspectLoaderGetCodeTestsc
Cs\tjd�}tjj|jd��}d|_|j�}|jd�}WdQRXt||j	�|j
|jd�dS)NrYrgz	attr = 42r�)rZr[r�patchr{r��return_value�get_coder�r�rOr�)r
r��mockedr~r�rrr�
test_get_code�s
z'InspectLoaderGetCodeTests.test_get_codec	CsBtjj|jd��}d|_|j�}|jd�}WdQRX|j|�dS)NrgrY)rr�r{r�r�r�rI)r
r�r~r�rrr�test_get_code_source_is_None�s
z6InspectLoaderGetCodeTests.test_get_code_source_is_Nonec	Cs,|j�}|jt��|jd�WdQRXdS)NrY)r�rVrWr�)r
r~rrr�test_get_code_source_not_found�sz8InspectLoaderGetCodeTests.test_get_code_source_not_foundN)rrr r�r�r�rrrrr��s
r�c@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�InspectLoaderLoadModuleTestsz!Test InspectLoader.load_module().rYcCs tj|j�|jtj|j�dS)N)rZunload�module_nameZ
addCleanup)r
rrrr
sz"InspectLoaderLoadModuleTests.setUpc
Cs>|jj|j|�}tj��tjdt�|jjj	|�SQRXdS)N�ignore)
rr|r��warnings�catch_warnings�simplefilter�DeprecationWarning�init�
_bootstrap�_load_unlocked)r
r~rTrrr�loads
z!InspectLoaderLoadModuleTests.loadcCstjj|jd�S)Nr�)rr�r{r�)r
rrr�
mock_get_codesz*InspectLoaderLoadModuleTests.mock_get_codecCsF|j��4}t|_|jt��|j�}|j|�WdQRXWdQRXdS)N)r�rW�side_effectrVr�r�)r
�mocked_get_coder~rrr�test_get_code_ImportErrors

z6InspectLoaderLoadModuleTests.test_get_code_ImportErrorcCsF|j��4}d|_|jt��|j�}|j|�WdQRXWdQRXdS)N)r�r�rVrWr�r�)r
r�r~rrr�test_get_code_Nones

z/InspectLoaderLoadModuleTests.test_get_code_NonecCsPtddd�}|j��2}||_|j�}|j|�}|j|tj|j�WdQRXdS)Nz	attr = 42z<string>r�)	�compiler�r�r�r�rOr�r�r�)r
r�r�r~r�rrr�test_module_returned's

z1InspectLoaderLoadModuleTests.test_module_returnedN)rrr r!r�rr�r�r�r�r�rrrrr�sr�)r�r�rc@s<eZdZddd�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ExecutionLoaderGetCodeTestsF)rgrlcCs8d\}}|rtjj|jd�}|r0tjj|jd�}||fS)Nrgrl)NN)rr�r{�ExecutionLoaderSubclass)r
rgrl�source_mock_context�filename_mock_contextrrr�mock_methods<s

z(ExecutionLoaderGetCodeTests.mock_methodsc	Cs�d}|jddd�\}}|�4}|�$}d|_||_|j�}|jd�}WdQRXWdQRX|j|j|�tjd�}t||j	�|j|j
d�dS)Nzblah.pyT)rgrlz	attr = 42rYr�)r�r�r�r�rOr�rZr[r�r�r�)	r
rEr�r��source_mock�	name_mockr~r�r�rrrr�Fs
z)ExecutionLoaderGetCodeTests.test_get_codec	CsF|jdd�\}}|�}d|_|j�}|jd�}WdQRX|j|�dS)NT)rgrY)r�r�r�r�rI)r
r��_r�r~r�rrrr�Tsz8ExecutionLoaderGetCodeTests.test_get_code_source_is_Nonec	Cs,|j�}|jt��|jd�WdQRXdS)NrY)r�rVrWr�)r
r~rrrr�]sz:ExecutionLoaderGetCodeTests.test_get_code_source_not_foundcCs�|jddd�\}}|�4}|�$}d|_t|_|j�}|jd�}WdQRXWdQRX|j|jd�tj	d�}t
||j�|j|jd�dS)NT)rgrlz	attr = 42rYz<string>r�)
r�r�rWr�r�r�rOr�rZr[r�r�r�)r
r�r�r�r�r~r�r�rrr�test_get_code_no_pathcs
z1ExecutionLoaderGetCodeTests.test_get_code_no_pathN)rrr r�r�r�r�r�rrrrr�:s

	r�)r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�SourceOnlyLoadersN_ = '::'.join([__name__, __file__, __cached__, __package__, repr(__loader__)])cCs
||_dS)N)rE)r
rErrr�__init__�szSourceOnlyLoader.__init__cCs||jkrt�|jS)N)rErdr�)r
rErrrrb�s
zSourceOnlyLoader.get_datacCs|jS)N)rE)r
rDrrrrl�szSourceOnlyLoader.get_filenamecCsdS)Nz<module>r)r
r�rrrr]�szSourceOnlyLoader.module_reprN)rrr r�r�rbrlr]rrrrr�zs
r�cs>eZdZdZd�fdd�	Z�fdd�Zdd�Zd	d
�Z�ZS)r2rNcs�t�j|�|jj|j�|_t|j�|_|dkr8|jj	}t
|�}|j|jj
|j��|j|jj
|j��t|j|jddd�}|jtj|��t|�|_i|_dS)Nr�T)�dont_inherit)rBr�r�cache_from_sourcerE�
bytecode_path�lenr��source_size�MAGIC_NUMBER�	bytearray�extendr��_w_long�source_mtimer��marshal�dumps�bytes�bytecode�written)r
rE�magicr��code_object)r?rrr��s
zSourceLoader.__init__cs.||jkrt�j|�S||jkr&|jSt�dS)N)rErBrbr�r��OSError)r
rE)r?rrrb�s


zSourceLoader.get_datacCs||jkrt�|j|jd�S)N)�mtime�size)rErdr�r�)r
rErrr�
path_stats�s
zSourceLoader.path_statscCst|�|j|<||jkS)N)r�r�r�)r
rEr�rrr�set_data�szSourceLoader.set_data)N)	rrr r�r�rbr�r�rFrr)r?rr2�s
)rr�c@s*eZdZdd�dd�Zdd�Zdd�Zd	S)
�SourceLoaderTestHarnessT)rfcKs~d|_|r&tjj|jd�|_|j|_n2d}tjj|jdjddg��|_dj|j|g�|_|jj|j�|_|j|jf|�|_	dS)NZpkgz__init__.pyr`�.�py)
�package�osrE�joinr3rr��cached�loader_mockr~)r
rfr:r�rrrr�s
zSourceLoaderTestHarness.setUpcCs�|j|j|j�|j|j|j�|j|j|j�|j|j|j�|j|j	|j
�|jjd�}|j|d|j�|j|d|j�|j|d|j�|j|d|j�|j|dt
|j
��dS)Nz::rr���)rOrr3�__file__rE�
__cached__r��__package__r�r_r~r��splitr^)r
r��valuesrrr�
verify_module�sz%SourceLoaderTestHarness.verify_modulecCsLtj|j�}|j|_|j|_|j|_|j	|_
g|_t||j
�|j|�dS)N)rZr[r3rEr�r�r�r�r�r~r_r�r�r�r�)r
r�r�rrr�verify_code�sz#SourceLoaderTestHarness.verify_codeN)rrr rr�r�rrrrr��s
r�c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�SourceOnlyLoaderTestsz�Test importlib.abc.SourceLoader for source-only loading.

    Reload testing is subsumed by the tests for
    importlib.util.module_for_loader.

    c
Csn|jjjd�}|j|jj|j�|�dd�}||j_|jt��}|jj|j�WdQRX|j|j	j|j�dS)Nzutf-8cSst�dS)N)r�)rErrr�
raise_OSError�sz<SourceOnlyLoaderTests.test_get_source.<locals>.raise_OSError)
r~r��decoderOrgr3rbrVrWZ	exception)r
Zexpected_sourcer��cmrrrrj�sz%SourceOnlyLoaderTests.test_get_sourcecCs\|jdd�|j|jj|j��|jdd�|j|jj|j��|j|jj|jd��dS)NF)rfTz	.__init__)r�assertFalser~rfr3r)r
rrrri�s
z%SourceOnlyLoaderTests.test_is_packagecCs|jj|j�}|j|�dS)N)r~r�r3r�)r
r�rrrr��sz#SourceOnlyLoaderTests.test_get_codecCs"|jj|jj|j�}|j|�dS)N)r~r�r�rEr�)r
r�rrr�test_source_to_codesz)SourceOnlyLoaderTests.test_source_to_codecCs~tj|j��htj�� tjdt�|jj|j�}WdQRX|j	|�|j
|jtj
j|j
�g�|j|jtj�WdQRXdS)Nr�)r9r�r3r�r�r�r�r~rQr�rOr�r�rE�dirname�assertInr�r�)r
r�rrrrXs

z&SourceOnlyLoaderTests.test_load_modulecCsp|jdd�tj|j��Ntj�� tjdt�|jj	|j�}WdQRX|j
|�|jt|d��WdQRXdS)NF)rfr�r�)
rr9r�r3r�r�r�r�r~rQr�r�r)r
r�rrr�test_package_settingss

z+SourceOnlyLoaderTests.test_package_settingscCs\d}|jd�|j_|jj|j�}|j||�d}|jd�|j_|jj|j�}|j||�dS)Nu_ = 'ü'zutf-8u# coding: latin-1
_ = üzlatin-1)�encoder~r�rgr3rO)r
r��returned_sourcerrr�test_get_source_encodingsz.SourceOnlyLoaderTests.test_get_source_encodingN)rrr r!rjrir�r�rXr�r�rrrrr��sr�)rr�zsys.dont_write_bytecode is truecs^eZdZdZdd��fdd�
Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Z�ZS)�SourceLoaderBytecodeTestszsTest importlib.abc.SourceLoader's use of bytecode.

    Source-only testing handled by SourceOnlyLoaderTests.

    F)�bytecode_writtencs�t�j|�|r�|j|j|jj�t|jj�}|j	|j
j|jj��|j	|j
j|jj
��|j	tj|��|j|jj|jt|��dS)N)rBr�r�r�r~r�r�rr�r�r�r�r�r�r�r�rOr�)r
r�r�r�)r?rrr�;sz%SourceLoaderBytecodeTests.verify_codecCs|jj|j�}|j|�dS)N)r~r�r3r�)r
r�rrr�test_code_with_everythingEsz3SourceLoaderBytecodeTests.test_code_with_everythingcCsXd|j_|jt�� |jj|j�}|jj|�WdQRX|jj|j	�}|j
|dd�dS)Nz<does not exist>T)r�)r~r�rVr�rr�rErbr�r3r�)r
r�r�rrr�test_no_bytecodeJsz*SourceLoaderBytecodeTests.test_no_bytecodecCsZxTdD]L}|jj}||j_|jjdd�|j_|jj|j�}|j|dd�||j_qWdS)Nrr��T)r�)rr�)r~r�r�r�r3r�)r
r�Zoriginalr�rrr�test_code_bad_timestampTs
z1SourceLoaderBytecodeTests.test_code_bad_timestampcCs@|jdd�|jjdd�|j_|jj|j�}|j|dd�dS)Ns0000)r�rT)r�)rr~r�r�r3r�)r
r�rrr�test_code_bad_magic`sz-SourceLoaderBytecodeTests.test_code_bad_magiccCs@z2dt_d|j_|jj|j�}|j|j|jj�Wddt_XdS)NTz<does not exist>F)	r��dont_write_bytecoder~r�r�r3ZassertNotInr�r�)r
r�rrr�test_dont_write_bytecodehsz2SourceLoaderBytecodeTests.test_dont_write_bytecodecCsd|jdd�|jjj�dj}z,|jjj�d`|jj|j�}|j|�Wd||jjj�d_XdS)Ns0000)r�r)rr~r?�mror�r�r3r�)r
Zoriginal_set_datar�rrr�test_no_set_datassz*SourceLoaderBytecodeTests.test_no_set_datacCs<dd�}|jdd�|t�|j_|jj|j�}|j|�dS)Ncs�fdd�}|S)Ncs��dS)Nr)�argsr:)�excrr�closure�szcSourceLoaderBytecodeTests.test_set_data_raises_exceptions.<locals>.raise_exception.<locals>.closurer)r	r
r)r	r�raise_exception�szRSourceLoaderBytecodeTests.test_set_data_raises_exceptions.<locals>.raise_exceptions0000)r�)rr\r~r�r�r3r�)r
rr�rrr�test_set_data_raises_exceptions~s
z9SourceLoaderBytecodeTests.test_set_data_raises_exceptions)
rrr r!r�r�rrrrrrrFrr)r?rr�2s

r�)r�rr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SourceLoaderGetSourceTestsz2Tests for importlib.abc.SourceLoader.get_source().cCs8d}|jd�}d}|jd�|_|j|�}|j||�dS)Nr`zmod.fileux = "ü"zutf-8)�SourceOnlyLoaderMockr�r�rgrO)r
r3rr�r�rrr�test_default_encoding�s

z0SourceLoaderGetSourceTests.test_default_encodingcCs8d}|jd�}d}|jd�|_|j|�}|j||�dS)Nr`zmod.fileu# coding: Latin-1
x='ü'zlatin-1)rr�r�rgrO)r
r3rr�r�rrr�test_decoded_source�s

z.SourceLoaderGetSourceTests.test_decoded_sourcecCsFd}|jd�}d}|jd�|_tjdd�j|�}|j|j|�|�dS)Nr`zmod.filezx = 42
y = -13
zutf-8T)rr�r��io�IncrementalNewlineDecoderr�rOrg)r
r3rr�Zexpectrrr�test_universal_newlines�s
z2SourceLoaderGetSourceTests.test_universal_newlinesN)rrr r!rrrrrrrr
�s	
r
)r�__main__)NF)g�
contextlib�inspectrr�r�r�ZtestrrZZunittestrr�r�rr9Zimport_importlibr�r
rrr"Z	test_bothZ%Frozen_MetaPathFinderInheritanceTestsZ%Source_MetaPathFinderInheritanceTestsr(Z&Frozen_PathEntryFinderInheritanceTestsZ&Source_PathEntryFinderInheritanceTestsr*Z%Frozen_ResourceLoaderInheritanceTestsZ%Source_ResourceLoaderInheritanceTestsr,Z$Frozen_InspectLoaderInheritanceTestsZ$Source_InspectLoaderInheritanceTestsr.Z&Frozen_ExecutionLoaderInheritanceTestsZ&Source_ExecutionLoaderInheritanceTestsr/Z!Frozen_FileLoaderInheritanceTestsZ!Source_FileLoaderInheritanceTestsr2Z#Frozen_SourceLoaderInheritanceTestsZ#Source_SourceLoaderInheritanceTestsr<r=rGZFrozen_MPFDefaultTestsZSource_MPFDefaultTestsrNZFrozen_PEFDefaultTestsZSource_PEFDefaultTestsr+rRZFrozen_LDefaultTestsZSourceLDefaultTestsrcZFrozen_RLDefaultTestsZSource_RLDefaultTestsrkrhZFrozen_ILDefaultTestsZSource_ILDefaultTestsrormZFrozen_ELDefaultTestsZSource_ELDefaultsTestsrpZFrozen_MPFFindModuleTestsZSource_MPFFindModuleTestsr�ZFrozen_PEFFindLoaderTestsZSource_PEFFindLoaderTestsr�ZFrozen_LoaderLoadModuleTestsZSource_LoaderLoadModuleTestsr�ZFrozen_ILSourceToCodeTestsZSource_ILSourceToCodeTestsr�ZFrozen_ILGetCodeTestsZSource_ILGetCodeTestsr�ZFrozen_ILLoadModuleTestsZSource_ILLoadModuleTestsr�ZFrozen_ELGetCodeTestsZSource_ELGetCodeTestsr�Z	SPLIT_SOLZSPLIT_SLr�r�ZFrozen_SourceOnlyLoaderTestsZSource_SourceOnlyLoaderTestsZskipIfrr�ZFrozen_SLBytecodeTestsZSourceSLBytecodeTestsr
Z%Frozen_SourceOnlyLoaderGetSourceTestsZ%Source_SourceOnlyLoaderGetSourceTestsr�mainrrrr�<module>s�



$
		'
-,/;
%&NZ
#