Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/test_importlib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/test_importlib/__pycache__/test_abc.cpython-35.pyc



��Yf�|�@s�ddlZddlZddlZddlZddlZddlZddlmZddlZddl	Z	ddl	m
Z
ddlZddlm
Zejd�Zejd�Zejd�Zejd	�Z
Gd
d�d�ZGdd
�d
e�Zejede�\ZZGdd�de�Zejede�\ZZGdd�de�Zejede�\ZZGdd�de�Zejede�\ZZ Gdd�de�Z!eje!de�\Z"Z#Gdd�de�Z$eje$de�\Z%Z&Gdd�de�Z'eje'de�\Z(Z)dddd�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�ZAejeAded5e
�\ZBZCGd6d7�d7�ZDejeDded5e
d8e�\ZEZFGd9d:�d:�ZGejeGded5e
�\ZHZIGd;d<�d<�ZJejeJd=e9�\ZKZLGd>d?�d?�ZMejeMd=e9�\ZNZOGd@dA�dA�ZPejePd=e9�\ZQZRGdBdC�dC�ZSejeSdDe=�\ZTZUGdEdF�dF�ZVe*eVd�ZWGdGd�deV�Z'e*e'd5e
dHe�ZXGdIdJ�dJ�ZYGdKdL�dLeY�ZZejeZd5e
dMeW�\Z[Z\e	j]ej^dN�GdOdP�dPeY��Z_eje_dHed5e
dMeX�\Z`ZaGdQdR�dR�ZbejebdSeW�\ZcZdeedTkr�e	jf�dS)U�N)�support)�mock�)�util�	importlibz
importlib.abczimportlib.machineryzimportlib.utilc@sFeZdZdZgZgZdd�Zdd�Zdd�ZdS)	�InheritanceTestszSTest that the specified class is a subclass/superclass of the expected
    classes.cs��fdd��jD��_t�d�rY�jj��fdd��jD��_�jsz�jszt�j��t	�j�j
��_dS)Ncs"g|]}t�j|��qS�)�getattr�abc)�.0�
class_name)�selfr�A/opt/alt/python35/lib64/python3.5/test/test_importlib/test_abc.py�
<listcomp>s	z*InheritanceTests.setUp.<locals>.<listcomp>�subclass_namescsg|]}t�|��qSr)r	)rr)�	machineryrrr(s	)�superclass_names�superclasses�hasattrr
rr�
subclasses�AssertionError�	__class__r	Z_NAME�_InheritanceTests__test)r
r)rr
r�setUps!zInheritanceTests.setUpcCsCx<|jD]1}|jt||j�dj||j��q
WdS)Nz{0} is not a subclass of {1})r�
assertTrue�
issubclassr�format)r
�subclassrrr�test_subclasses-sz InheritanceTests.test_subclassescCsCx<|jD]1}|jt|j|�dj||j��q
WdS)Nz{0} is not a superclass of {1})rrrrr)r
Z
superclassrrr�test_superclasses3sz"InheritanceTests.test_superclassesN)	�__name__�
__module__�__qualname__�__doc__rrrrrrrrrrsrc@s+eZdZdgZddddgZdS)�MetaPathFinder�Finder�BuiltinImporter�FrozenImporter�
PathFinder�WindowsRegistryFinderN)r r!r"rrrrrrr$:s		r$r
c@s"eZdZdgZdgZdS)�PathEntryFinderr%�
FileFinderN)r r!r"rrrrrrr*Es	r*c@seZdZdgZdS)�ResourceLoader�LoaderN)r r!r"rrrrrr,Osr,c@s(eZdZdgZdddgZdS)�
InspectLoaderr-r&r'�ExtensionFileLoaderN)r r!r"rrrrrrr.Xs	r.c@s"eZdZdgZdgZdS)�ExecutionLoaderr.r/N)r r!r"rrrrrrr0bs	r0c@s(eZdZddgZddgZdS)�
FileLoaderr,r0�SourceFileLoader�SourcelessFileLoaderN)r r!r"rrrrrrr1lsr1c@s%eZdZddgZdgZdS)�SourceLoaderr,r0r2N)r r!r"rrrrrrr4vsr4FcsZ�dkr|j��fdd�tj�D�}�fdd�tj|||�D�S)Ncs(i|]\}}t|��|�qSr)r	)rZkindZsplitabc)�namerr�
<dictcomp>�s	z'make_abc_subclasses.<locals>.<dictcomp>cs+i|]!}�r|�n||j�qSr)�_KIND)r�cls)�instrrr6�s	)r r
�items�	test_utilZsplit_frozen)Z
base_classr5r9�kwargs�baser)r9r5r�make_abc_subclasses�s	r>c@s"eZdZedd��ZdS)�ABCTestHarnesscCs)|j|j}|�}||j_|S)N)�SPLITr7r�ins)r
r8rArrrrA�s	zABCTestHarness.insN)r r!r"�propertyrArrrrr?�sr?cs"eZdZ�fdd�Z�S)r$cst�j||�S)N)�super�find_module)r
�fullname�path)rrrrD�szMetaPathFinder.find_module)r r!r"rDrr)rrr$�sc@s4eZdZee�Zdd�Zdd�ZdS)�MetaPathFinderDefaultsTestscCs |j|jjdd��dS)N�	something)�assertIsNonerArD)r
rrr�test_find_module�sz,MetaPathFinderDefaultsTests.test_find_modulecCs|jj�dS)N)rA�invalidate_caches)r
rrr�test_invalidate_caches�sz2MetaPathFinderDefaultsTests.test_invalidate_cachesN)r r!r"r>r$r@rJrLrrrrrG�srGcs"eZdZ�fdd�Z�S)r*cst�j|�S)N)rC�find_loader)r
rE)rrrrM�szPathEntryFinder.find_loader)r r!r"rMrr)rrr*�sc@s@eZdZee�Zdd�Zdd�Zdd�ZdS)�PathEntryFinderDefaultsTestscCs&|jdgf|jjd��dS)NrH)�assertEqualrArM)r
rrr�test_find_loader�sz-PathEntryFinderDefaultsTests.test_find_loadercCs |jd|jjd��dS)NrH)rOrArD)r
rrrrD�sz(PathEntryFinderDefaultsTests.find_modulecCs|jj�dS)N)rArK)r
rrrrL�sz3PathEntryFinderDefaultsTests.test_invalidate_cachesN)	r r!r"r>r*r@rPrDrLrrrrrN�srNcs"eZdZ�fdd�Z�S)r-cst�j|�S)N)rC�load_module)r
rE)rrrrQ�szLoader.load_module)r r!r"rQrr)rrr-�sr-c@s4eZdZee�Zdd�Zdd�ZdS)�LoaderDefaultsTestsc	Cs+|jt��|jjd�WdQRXdS)NrH)�assertRaises�ImportErrorrArQ)r
rrr�test_load_module�sz$LoaderDefaultsTests.test_load_modulec
Csetjd�}|jt��|jj|�WdQRXt|�}|j|_|jt|��dS)N�blah)	�types�
ModuleTyperS�NotImplementedErrorrA�module_repr�repr�
__loader__r)r
�modZ
original_reprrrr�test_module_repr�sz$LoaderDefaultsTests.test_module_reprN)r r!r"r>r-r@rUr^rrrrrR�srRcs"eZdZ�fdd�Z�S)r,cst�j|�S)N)rC�get_data)r
rF)rrrr_�szResourceLoader.get_data)r r!r"r_rr)rrr,�sc@s(eZdZee�Zdd�ZdS)�ResourceLoaderDefaultsTestsc	Cs+|jt��|jjd�WdQRXdS)Nz
/some/path)rS�IOErrorrAr_)r
rrr�
test_get_data�sz)ResourceLoaderDefaultsTests.test_get_dataN)r r!r"r>r,r@rbrrrrr`�sr`cs4eZdZ�fdd�Z�fdd�Z�S)r.cst�j|�S)N)rC�
is_package)r
rE)rrrrc�szInspectLoader.is_packagecst�j|�S)N)rC�
get_source)r
rE)rrrrd�szInspectLoader.get_source)r r!r"rcrdrr)rrr.�sc@s.eZdZeZdd�Zdd�ZdS)�InspectLoaderDefaultsTestsc	Cs+|jt��|jjd�WdQRXdS)NrV)rSrTrArc)r
rrr�test_is_package	sz*InspectLoaderDefaultsTests.test_is_packagec	Cs+|jt��|jjd�WdQRXdS)NrV)rSrTrArd)r
rrr�test_get_source
sz*InspectLoaderDefaultsTests.test_get_sourceN)r r!r"�SPLIT_ILr@rfrgrrrrresrecs"eZdZ�fdd�Z�S)r0cst�j|�S)N)rC�get_filename)r
rE)rrrriszExecutionLoader.get_filename)r r!r"rirr)rrr0sc@s"eZdZeZdd�ZdS)�ExecutionLoaderDefaultsTestsc	Cs+|jt��|jjd�WdQRXdS)NrV)rSrTrAri)r
rrr�test_get_filename$sz.ExecutionLoaderDefaultsTests.test_get_filenameN)r r!r"�SPLIT_ELr@rkrrrrrj srjc@s:eZdZedd��Zdd�Zdd�ZdS)�MetaPathFinderFindModuleTestscs)G�fdd�d|jj�}|�S)Ncs%eZdZd�fdd�ZdS)z@MetaPathFinderFindModuleTests.finder.<locals>.MetaPathSpecFinderNcs||f|_�S)N)�
called_for)r
rErF�target)�specrr�	find_spec5szJMetaPathFinderFindModuleTests.finder.<locals>.MetaPathSpecFinder.find_spec)r r!r"rqr)rprr�MetaPathSpecFinder3srr)r
r$)r8rprrr)rpr�finder1s"z$MetaPathFinderFindModuleTests.findercCsu|jd�}dddg}d}|j||�}|j|�|j||jd�|j||jd�dS)N�a�b�crVrr)rsrDrIrOrn)r
rsrFr5�foundrrr�test_no_spec;s
z*MetaPathFinderFindModuleTests.test_no_speccCsVt�}|jjd|�}|j|�}|jdd�}|j||j�dS)NrV)�objectr�spec_from_loaderrsrD�assertIs�loader)r
r|rprsrwrrr�	test_specDs
	z'MetaPathFinderFindModuleTests.test_specN)r r!r"�classmethodrsrxr}rrrrrm/s
	rmrc@sFeZdZedd��Zdd�Zdd�Zdd�Zd	S)
�PathEntryFinderFindLoaderTestscs)G�fdd�d|jj�}|�S)Ncs%eZdZd�fdd�ZdS)zBPathEntryFinderFindLoaderTests.finder.<locals>.PathEntrySpecFinderNcs
||_�S)N)rn)r
rEro)rprrrqXs	zLPathEntryFinderFindLoaderTests.finder.<locals>.PathEntrySpecFinder.find_spec)r r!r"rqr)rprr�PathEntrySpecFinderVsr�)r
r*)r8rpr�r)rprrsTs"z%PathEntryFinderFindLoaderTests.findercCs`|jd�}d}|j|�}|j|d�|jg|d�|j||j�dS)NrVrr)rsrMrIrOrn)r
rsr5rwrrrrx^sz+PathEntryFinderFindLoaderTests.test_no_speccCsWt�}|jjd|�}|j|�}|jd�}|j|d|j�dS)NrVr)ryrrzrsrMr{r|)r
r|rprsrwrrr�test_spec_with_loaderfs
	z4PathEntryFinderFindLoaderTests.test_spec_with_loadercCst|jjdd�}dddg}||_|j|�}|jd�}|j|d�|j||d�dS)NrVrtrurvrr)r�
ModuleSpec�submodule_search_locationsrsrMrIrO)r
rp�pathsrsrwrrr�test_spec_with_portionsms	z6PathEntryFinderFindLoaderTests.test_spec_with_portionsN)r r!r"r~rsrxr�r�rrrrrRs
rrc@s4eZdZdd�Zdd�Zdd�ZdS)�LoaderLoadModuleTestscCs#Gdd�d|jj�}|�S)Nc@s.eZdZdZdd�Zdd�ZdS)z0LoaderLoadModuleTests.loader.<locals>.SpecLoaderNcSs
||_dS)N)rw)r
�modulerrr�exec_module�sz<LoaderLoadModuleTests.loader.<locals>.SpecLoader.exec_modulecSsdS)z.Force some non-default module state to be set.Tr)r
rErrrrc�sz;LoaderLoadModuleTests.loader.<locals>.SpecLoader.is_package)r r!r"rwr�rcrrrr�
SpecLoader�sr�)r
r-)r
r�rrrr|�s	zLoaderLoadModuleTests.loaderc
Cs�|j�}d}tj|��2|j|�|j}|jtj||�WdQRX|j||j	�|j||j
j�|j||j�|j||j
j�|j
|j�|j
|j|j
j�dS)NrV)r|r;�uncacherQrwr{�sys�modulesrOr\�__spec__r r5ZassertIsNotNone�__path__r�)r
r|r5r�rrr�
test_fresh�s
	z LoaderLoadModuleTests.test_freshcCs�d}|j�}tj|�}|jj||�|_||_tj|��V|t	j
|<|j|�|j}|j
|t	j
|�|j
|t	j
|�WdQRXdS)NrV)r|rWrXrrzr�r\r;r�r�r�rQrwr{)r
r5r|r�rwrrr�test_reload�s	

	z!LoaderLoadModuleTests.test_reloadN)r r!r"r|r�r�rrrrr�~sr�c@sOeZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�InspectLoaderSourceToCodeTestsNcCs_tjd�}|j�}|dkr9|j|�}n|j||�}t||j�|S)z!Help with source_to_code() tests.rVN)rWrX�InspectLoaderSubclass�source_to_code�exec�__dict__)r
�datarFr�r|�coderrr�source_to_module�sz/InspectLoaderSourceToCodeTests.source_to_modulecCsBd}|j|�}|jt|d��|j|jd�dS)Nz	attr = 42�attr�*)r�rrrOr�)r
�sourcer�rrr�test_source_to_code_source�sz9InspectLoaderSourceToCodeTests.test_source_to_code_sourcecCsBd}|j|�}|jt|d��|j|jd�dS)Ns	attr = 42r�r�)r�rrrOr�)r
r�r�rrr�test_source_to_code_bytes�sz8InspectLoaderSourceToCodeTests.test_source_to_code_bytescCs;d}|j�}|jd|�}|j|j|�dS)Nzpath/to/somewhere�)r�r�rO�co_filename)r
rFr|r�rrr�test_source_to_code_path�sz7InspectLoaderSourceToCodeTests.test_source_to_code_pathcCs2|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)r r!r"r�r�r�r�r�rrrrr��s
r�r�c@s4eZdZdd�Zdd�Zdd�ZdS)�InspectLoaderGetCodeTestsc
Cs|tjd�}tjj|jd��+}d|_|j�}|jd�}WdQRXt||j	�|j
|jd�dS)NrVrdz	attr = 42r�)rWrXr�patchryr��return_value�get_coder�r�rOr�)r
r��mockedr|r�rrr�
test_get_code�s	z'InspectLoaderGetCodeTests.test_get_codec	CsWtjj|jd��+}d|_|j�}|jd�}WdQRX|j|�dS)NrdrV)rr�ryr�r�r�rI)r
r�r|r�rrr�test_get_code_source_is_None�s
	z6InspectLoaderGetCodeTests.test_get_code_source_is_Nonec	Cs4|j�}|jt��|jd�WdQRXdS)NrV)r�rSrTr�)r
r|rrr�test_get_code_source_not_found�sz8InspectLoaderGetCodeTests.test_get_code_source_not_foundN)r r!r"r�r�r�rrrrr��s
r�c@sXeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�InspectLoaderLoadModuleTestsz!Test InspectLoader.load_module().rVcCs*tj|j�|jtj|j�dS)N)rZunload�module_nameZ
addCleanup)r
rrrrsz"InspectLoaderLoadModuleTests.setUpcCstjj|jd�S)Nr�)rr�ryr�)r
rrr�
mock_get_code
sz*InspectLoaderLoadModuleTests.mock_get_codecCsz|j��g}t|_|jt��E|j�}tj��%tjdt�|j	|j
�WdQRXWdQRXWdQRXdS)N�ignore)r�rT�side_effectrSr��warnings�catch_warnings�simplefilter�DeprecationWarningrQr�)r
�mocked_get_coder|rrr�test_get_code_ImportError
s	
z6InspectLoaderLoadModuleTests.test_get_code_ImportErrorcCsV|j��C}d|_|jt��!|j�}|j|j�WdQRXWdQRXdS)N)r�r�rSrTr�rQr�)r
r�r|rrr�test_get_code_Nones
	z/InspectLoaderLoadModuleTests.test_get_code_NonecCsmtddd�}|j��H}||_|j�}|j|j�}|j|tj|j�WdQRXdS)Nz	attr = 42z<string>r�)	�compiler�r�r�rQr�rOr�r�)r
r�r�r|r�rrr�test_module_returneds	z1InspectLoaderLoadModuleTests.test_module_returnedN)
r r!r"r#r�rr�r�r�r�rrrrr�s
r�c@sXeZdZdddddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)�ExecutionLoaderGetCodeTestsrdFricCsRd\}}|r*tjj|jd�}|rHtjj|jd�}||fS)Nrdri)NN)rr�ry�ExecutionLoaderSubclass)r
rdri�source_mock_context�filename_mock_contextrrr�mock_methods2s		z(ExecutionLoaderGetCodeTests.mock_methodsc	Cs�d}|jdddd�\}}|�D}|�4}d|_||_|j�}|jd�}WdQRXWdQRX|j|j|�tjd�}t||j	�|j|j
d�dS)Nzblah.pyrdTriz	attr = 42rVr�)r�r�r�r�rOr�rWrXr�r�r�)	r
rFr�r��source_mock�	name_mockr|r�r�rrrr�<s			z)ExecutionLoaderGetCodeTests.test_get_codec	Cs]|jdd�\}}|�+}d|_|j�}|jd�}WdQRX|j|�dS)NrdTrV)r�r�r�r�rI)r
r��_r�r|r�rrrr�Js		z8ExecutionLoaderGetCodeTests.test_get_code_source_is_Nonec	Cs4|j�}|jt��|jd�WdQRXdS)NrV)r�rSrTr�)r
r|rrrr�Ssz:ExecutionLoaderGetCodeTests.test_get_code_source_not_foundcCs�|jdddd�\}}|�D}|�4}d|_t|_|j�}|jd�}WdQRXWdQRX|j|jd�tj	d�}t
||j�|j|jd�dS)NrdTriz	attr = 42rVz<string>r�)
r�r�rTr�r�r�rOr�rWrXr�r�r�)r
r�r�r�r�r|r�r�rrr�test_get_code_no_pathYs			z1ExecutionLoaderGetCodeTests.test_get_code_no_pathN)r r!r"r�r�r�r�r�rrrrr�0s

	r�r�c@sFeZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�SourceOnlyLoadersN_ = '::'.join([__name__, __file__, __cached__, __package__, repr(__loader__)])cCs
||_dS)N)rF)r
rFrrr�__init__vszSourceOnlyLoader.__init__cCs||jkrt�|jS)N)rFrar�)r
rFrrrr_yszSourceOnlyLoader.get_datacCs|jS)N)rF)r
rErrrri~szSourceOnlyLoader.get_filenamecCsdS)Nz<module>r)r
r�rrrrZ�szSourceOnlyLoader.module_reprN)r r!r"r�r�r_rirZrrrrr�ps
r�csUeZdZdZd�fdd�Z�fdd�Zdd�Zd	d
�Z�S)r4rNcs�t�j|�|jj|j�|_t|j�|_|dkrR|jj	}t
|�}|j|jj
|j��|j|jj
|j��t|j|jddd�}|jtj|��t|�|_i|_dS)Nr��dont_inheritT)rCr�r�cache_from_sourcerF�
bytecode_path�lenr��source_size�MAGIC_NUMBER�	bytearray�extend�init�_w_long�source_mtimer��marshal�dumps�bytes�bytecode�written)r
rF�magicr��code_object)rrrr��s	zSourceLoader.__init__cs?||jkrt�j|�S||jkr5|jSt�dS)N)rFrCr_r�r��OSError)r
rF)rrrr_�s
zSourceLoader.get_datacCs+||jkrt�d|jd|jiS)N�mtime�size)rFrar�r�)r
rFrrr�
path_stats�szSourceLoader.path_statscCs t|�|j|<||jkS)N)r�r�r�)r
rFr�rrr�set_data�szSourceLoader.set_data)r r!r"r�r�r_r�r�rr)rrr4�s
r�c@s:eZdZdddd�Zdd�Zdd�Zd	S)
�SourceLoaderTestHarnessrcTcKs�d|_|r9tjj|jd�|_|j|_nKd}tjj|jdjddg��|_dj|j|g�|_|jj|j�|_|j|j|�|_	dS)NZpkgz__init__.pyr]�.�py)
�package�osrF�joinr5rr��cached�loader_mockr|)r
rcr<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���)rOr r5�__file__rF�
__cached__r��__package__r�r\r|r��splitr[)r
r��valuesrrr�
verify_module�sz%SourceLoaderTestHarness.verify_modulecCsltj|j�}|j|_|j|_|j|_|j	|_
g|_t||j
�|j|�dS)N)rWrXr5rFr�r�r�r�r�r|r\r�r�r�r�)r
r�r�rrr�verify_code�s	z#SourceLoaderTestHarness.verify_codeN)r r!r"rr�r�rrrrr��s
r�c@sjeZdZdZdd�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
Cs�|jjjd�}|j|jj|j�|�dd�}||j_|jt��}|jj|j�WdQRX|j|j	j|j�dS)Nzutf-8cSs
t�dS)N)r�)rFrrr�
raise_OSError�sz<SourceOnlyLoaderTests.test_get_source.<locals>.raise_OSError)
r|r��decoderOrdr5r_rSrTZ	exception)r
Zexpected_sourcer��cmrrrrg�sz%SourceOnlyLoaderTests.test_get_sourcecCs||jdd�|j|jj|j��|jdd�|j|jj|j��|j|jj|jd��dS)NrcFTz	.__init__)r�assertFalser|rcr5r)r
rrrrf�s
z%SourceOnlyLoaderTests.test_is_packagecCs&|jj|j�}|j|�dS)N)r|r�r5r�)r
r�rrrr��sz#SourceOnlyLoaderTests.test_get_codecCs/|jj|jj|j�}|j|�dS)N)r|r�r�rFr�)r
r�rrr�test_source_to_code�sz)SourceOnlyLoaderTests.test_source_to_codecCs�tj|j���tj��*tjdt�|jj|j�}WdQRX|j	|�|j
|jtj
j|j
�g�|j|jtj�WdQRXdS)Nr�)r;r�r5r�r�r�r�r|rQr�rOr�r�rF�dirname�assertInr�r�)r
r�rrrrU�s

%z&SourceOnlyLoaderTests.test_load_modulecCs�|jdd�tj|j��atj��*tjdt�|jj	|j�}WdQRX|j
|�|jt|d��WdQRXdS)NrcFr�r�)
rr;r�r5r�r�r�r�r|rQr�r�r)r
r�rrr�test_package_settings	s

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�rdr5rO)r
r��returned_sourcerrr�test_get_source_encodingsz.SourceOnlyLoaderTests.test_get_source_encodingN)r r!r"r#rgrfr�r�rUr�r�rrrrr��sr�r�zsys.dont_write_bytecode is truecs�eZdZdZdd�fdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Z�S)�SourceLoaderBytecodeTestszsTest importlib.abc.SourceLoader's use of bytecode.

    Source-only testing handled by SourceOnlyLoaderTests.

    �bytecode_writtenFcs�t�j|�|r�|j|j|jj�t|jj�}|j	|j
j|jj��|j	|j
j|jj
��|j	tj|��|j|jj|jt|��dS)N)rCr�r�r�r|r�r�rr�r�r�r�r�r�r�r�rOr�)r
r�r�r�)rrrr�1sz%SourceLoaderBytecodeTests.verify_codecCs&|jj|j�}|j|�dS)N)r|r�r5r�)r
r�rrr�test_code_with_everything;sz3SourceLoaderBytecodeTests.test_code_with_everythingcCstd|j_|jt��*|jj|j�}|jj|�WdQRX|jj|j	�}|j
|dd�dS)Nz<does not exist>r�T)r|r�rSr�rr�rFr_r�r5r�)r
r�r�rrr�test_no_bytecode@sz*SourceLoaderBytecodeTests.test_no_bytecodecCs�x�dD]�}||jjks%t�|jj}||j_|jjdd�|j_|jj|j�}|j|dd�||j_qWdS)Nrr��r�T)rr�)r|r�rr�r�r5r�)r
r�Zoriginalr�rrr�test_code_bad_timestampJs
z1SourceLoaderBytecodeTests.test_code_bad_timestampcCsX|jdd�|jjdd�|j_|jj|j�}|j|dd�dS)Nr�s0000r�r�T)rr|r�r�r5r�)r
r�rrr�test_code_bad_magicVsz-SourceLoaderBytecodeTests.test_code_bad_magiccCsXzGdt_d|j_|jj|j�}|j|j|jj�Wddt_XdS)NTz<does not exist>F)	r��dont_write_bytecoder|r�r�r5ZassertNotInr�r�)r
r�rrr�test_dont_write_bytecode^s	z2SourceLoaderBytecodeTests.test_dont_write_bytecodecCs�|jdd�|jjj�dj}z<|jjj�d`|jj|j�}|j|�Wd||jjj�d_XdS)Nr�s0000r)rr|r�mror�r�r5r�)r
Zoriginal_set_datar�rrr�test_no_set_dataisz*SourceLoaderBytecodeTests.test_no_set_datacCsTdd�}|jdd�|t�|j_|jj|j�}|j|�dS)Ncs�fdd�}|S)Ncs
��dS)Nr)�argsr<)�excrr�closurewszcSourceLoaderBytecodeTests.test_set_data_raises_exceptions.<locals>.raise_exception.<locals>.closurer)rrr)rr�raise_exceptionvszRSourceLoaderBytecodeTests.test_set_data_raises_exceptions.<locals>.raise_exceptionr�s0000)rrYr|r�r�r5r�)r
rr�rrr�test_set_data_raises_exceptionsts
z9SourceLoaderBytecodeTests.test_set_data_raises_exceptions)r r!r"r#r�r�r�r�r�rrrrr)rrr�(s

r�c@s:eZdZdZdd�Zdd�Zdd�ZdS)	�SourceLoaderGetSourceTestsz2Tests for importlib.abc.SourceLoader.get_source().cCsPd}|jd�}d}|jd�|_|j|�}|j||�dS)Nr]zmod.fileux = "ü"zutf-8)�SourceOnlyLoaderMockr�r�rdrO)r
r5rr�r�rrr�test_default_encoding�sz0SourceLoaderGetSourceTests.test_default_encodingcCstd}|jd�}d}|jd�|jd�ks?t�|jd�|_|j|�}|j||�dS)Nr]zmod.fileu# coding: Latin-1
x='ü'zlatin-1zutf-8)r	r�rr�rdrO)r
r5rr�r�rrr�test_decoded_source�s$z.SourceLoaderGetSourceTests.test_decoded_sourcecCsed}|jd�}d}|jd�|_tjdd�j|�}|j|j|�|�dS)Nr]zmod.filezx = 42
y = -13
zutf-8T)r	r�r��io�IncrementalNewlineDecoderr�rOrd)r
r5rr�Zexpectrrr�test_universal_newlines�sz2SourceLoaderGetSourceTests.test_universal_newlinesN)r r!r"r#r
rrrrrrr�s	
rr	�__main__)g�
contextlib�inspectrr�r�r�ZtestrrWZunittestrr�r�rr;Zimport_importlibr�r
rrr$Z	test_bothZ%Frozen_MetaPathFinderInheritanceTestsZ%Source_MetaPathFinderInheritanceTestsr*Z&Frozen_PathEntryFinderInheritanceTestsZ&Source_PathEntryFinderInheritanceTestsr,Z%Frozen_ResourceLoaderInheritanceTestsZ%Source_ResourceLoaderInheritanceTestsr.Z$Frozen_InspectLoaderInheritanceTestsZ$Source_InspectLoaderInheritanceTestsr0Z&Frozen_ExecutionLoaderInheritanceTestsZ&Source_ExecutionLoaderInheritanceTestsr1Z!Frozen_FileLoaderInheritanceTestsZ!Source_FileLoaderInheritanceTestsr4Z#Frozen_SourceLoaderInheritanceTestsZ#Source_SourceLoaderInheritanceTestsr>r?rGZFrozen_MPFDefaultTestsZSource_MPFDefaultTestsrNZFrozen_PEFDefaultTestsZSource_PEFDefaultTestsr-rRZFrozen_LDefaultTestsZSourceLDefaultTestsr`ZFrozen_RLDefaultTestsZSource_RLDefaultTestsrhreZFrozen_ILDefaultTestsZSource_ILDefaultTestsrlrjZFrozen_ELDefaultTestsZSource_ELDefaultsTestsrmZFrozen_MPFFindModuleTestsZSource_MPFFindModuleTestsrZFrozen_PEFFindLoaderTestsZSource_PEFFindLoaderTestsr�ZFrozen_LoaderLoadModuleTestsZSource_LoaderLoadModuleTestsr�ZFrozen_ILSourceToCodeTestsZSource_ILSourceToCodeTestsr�ZFrozen_ILGetCodeTestsZSource_ILGetCodeTestsr�ZFrozen_ILLoadModuleTestsZSource_ILLoadModuleTestsr�ZFrozen_ELGetCodeTestsZSource_ELGetCodeTestsr�Z	SPLIT_SOLZSPLIT_SLr�r�ZFrozen_SourceOnlyLoaderTestsZSource_SourceOnlyLoaderTestsZskipIfr�r�ZFrozen_SLBytecodeTestsZSourceSLBytecodeTestsrZ%Frozen_SourceOnlyLoaderGetSourceTestsZ%Source_SourceOnlyLoaderGetSourceTestsr �mainrrrr�<module>s�$		!'-!,+;%&NZ#