Your IP : 216.73.217.32


Current Path : /opt/alt/python39/lib64/python3.9/test/test_importlib/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/test_importlib/__pycache__/test_abc.cpython-39.pyc

a

XC?h؅�@s�ddlZddlZddlZddlZddlmZddlZddlZddlmZddl	Z	ddl
mZe�
d�Ze�
d�Ze�
d�Ze�
d	�ZGd
d�d�ZGdd
�d
e�Zejeed�\ZZGdd�de�Zejeed�\ZZGdd�de�Zejeed�\ZZGdd�de�Zejeed�\ZZGdd�de�Zejeed�\Z Z!Gdd�de�Z"eje"ed�\Z#Z$Gdd�de�Z%eje%ed�\Z&Z'd[dd�Z(Gdd�d�Z)Gd d
�d
�ZGd!d"�d"e)�Z*e�e*�\Z+Z,Gd#d�d�ZGd$d%�d%e)�Z-e�e-�\Z.Z/Gd&d'�d'�Z0Gd(d)�d)e)�Z1e�e1�\Z2Z3Gd*d�de0�ZGd+d,�d,e)�Z4e�e4�\Z5Z6Gd-d�de0�Ze(e�Z7Gd.d/�d/e)�Z8e�e8�\Z9Z:Gd0d�de�Ze(e�Z;Gd1d2�d2e)�Z<e�e8�\Z=Z>Gd3d4�d4�Z?Gd5d6�d6e)�Z@e�e@�\ZAZBGd7d8�d8�ZCejeCeed9�\ZDZEGd:d;�d;�ZFejeFeeed<�\ZGZHGd=d>�d>�ZIejeIeed9�\ZJZKGd?d@�d@�ZLejeLe7dA�\ZMZNGdBdC�dC�ZOejeOe7dA�\ZPZQGdDdE�dE�ZRejeRe7eedF�\ZSZTGdGdH�dH�ZUejeUe;dI�\ZVZWGdJdK�dK�ZXe(eXd�ZYGdLd�deX�Z%e(e%eedM�ZZGdNdO�dO�Z[GdPdQ�dQe[�Z\eje\eeYdR�\Z]Z^e�_ej`dS�GdTdU�dUe[��ZaejeaeeeZdV�\ZbZcGdWdX�dX�ZdejedeYdY�\ZeZfegdZk�r�e�h�dS)\�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.csh�fdd��jD��_t�d�r>�jj��fdd��jD��_�jsT�jsTJ�j��t�j�j	��_
dS)Ncsg|]}t�j|��qS�)�getattr�abc��.0�
class_name��selfr�A/opt/alt/python39/lib64/python3.9/test/test_importlib/test_abc.py�
<listcomp>s�z*InheritanceTests.setUp.<locals>.<listcomp>�subclass_namescsg|]}t�|��qSr�r	r)�	machineryrrr&s�)�superclass_names�superclasses�hasattrr
rr�
subclasses�	__class__r	Z_NAME�_InheritanceTests__testrr)rrr�setUps
�

�zInheritanceTests.setUpcCs.|jD]"}|�t||j�d�||j��qdS)Nz{0} is not a subclass of {1})r�
assertTrue�
issubclassr�format)r�subclassrrr�test_subclasses+s
�z InheritanceTests.test_subclassescCs.|jD]"}|�t|j|�d�||j��qdS)Nz{0} is not a superclass of {1})rrrrr)rZ
superclassrrr�test_superclasses1s
�z"InheritanceTests.test_superclassesN)	�__name__�
__module__�__qualname__�__doc__rrrr r!rrrrrsrc@seZdZdgZgd�ZdS)�MetaPathFinder�Finder)�BuiltinImporter�FrozenImporter�
PathFinder�WindowsRegistryFinderN�r"r#r$rrrrrrr&8sr&)r
c@seZdZdgZdgZdS)�PathEntryFinderr'�
FileFinderNr,rrrrr-Csr-c@seZdZdgZdS)�ResourceLoader�LoaderN)r"r#r$rrrrrr/Msr/c@seZdZdgZgd�ZdS)�
InspectLoaderr0)r(r)�ExtensionFileLoaderNr,rrrrr1Vsr1c@seZdZdgZdgZdS)�ExecutionLoaderr1r2Nr,rrrrr3`sr3c@seZdZddgZddgZdS)�
FileLoaderr/r3�SourceFileLoader�SourcelessFileLoaderNr,rrrrr4jsr4c@seZdZddgZdgZdS)�SourceLoaderr/r3r5Nr,rrrrr7tsr7FcsF�dur|j��fdd�t��D�}�fdd�tj||fi|��D�S)Ncsi|]\}}|t|���qSrr)r�kindZsplitabc)�namerr�
<dictcomp>�s�z'make_abc_subclasses.<locals>.<dictcomp>csi|]}|j�r|�n|�qSr)�_KIND)r�cls)�instrrr:�s�)r"r
�items�	test_utilZsplit_frozen)Z
base_classr9r=�kwargs�baser)r=r9r�make_abc_subclasses�s
�
�rBc@seZdZedd��ZdS)�ABCTestHarnesscCs|j|j}|�}||j_|S�N)�SPLITr;r�ins)rr<rFrrrrF�szABCTestHarness.insN)r"r#r$�propertyrFrrrrrC�srCcseZdZ�fdd�Z�ZS)r&cst��||�SrD)�super�find_module)r�fullname�path�rrrrI�szMetaPathFinder.find_module)r"r#r$rI�
__classcell__rrrLrr&�sc@s$eZdZee�Zdd�Zdd�ZdS)�MetaPathFinderDefaultsTestscCsF|�t��|j�dd�}Wd�n1s.0Y|�|�dS�NZ	something)�assertWarns�DeprecationWarningrFrI�assertIsNone�r�foundrrr�test_find_module�s,z,MetaPathFinderDefaultsTests.test_find_modulecCs|j��dSrD�rF�invalidate_cachesrrrr�test_invalidate_caches�sz2MetaPathFinderDefaultsTests.test_invalidate_cachesN)r"r#r$rBr&rErUrXrrrrrN�srNcseZdZ�fdd�Z�ZS)r-cst��|�SrD)rH�find_loader�rrJrLrrrY�szPathEntryFinder.find_loader)r"r#r$rYrMrrrLrr-�sc@s,eZdZee�Zdd�Zdd�Zdd�ZdS)�PathEntryFinderDefaultsTestscCsJ|�t��|j�d�}Wd�n1s,0Y|�|dgf�dSrO)rPrQrFrY�assertEqualrSrrr�test_find_loader�s*z-PathEntryFinderDefaultsTests.test_find_loadercCs|�d|j�d��dSrO)r\rFrIrrrrrI�sz(PathEntryFinderDefaultsTests.find_modulecCs|j��dSrDrVrrrrrX�sz3PathEntryFinderDefaultsTests.test_invalidate_cachesN)	r"r#r$rBr-rEr]rIrXrrrrr[�sr[cseZdZ�fdd�Z�ZS)r0cst��|�SrD)rH�load_modulerZrLrrr^�szLoader.load_module)r"r#r$r^rMrrrLrr0�sr0c@s,eZdZee�Zdd�Zdd�Zdd�ZdS)�LoaderDefaultsTestscCsd}|�|j�|��dS)Nza spec)rRrF�
create_module)r�specrrr�test_create_module�sz&LoaderDefaultsTests.test_create_modulecCs:|�t��|j�d�Wd�n1s,0YdSrO)�assertRaises�ImportErrorrFr^rrrr�test_load_module�sz$LoaderDefaultsTests.test_load_modulecCsbt�d�}|�t��|j�|�Wd�n1s60Yt|�}|j|_|�t|��dS�N�blah)	�types�
ModuleTyperc�NotImplementedErrorrF�module_repr�repr�
__loader__r)r�modZ
original_reprrrr�test_module_repr�s
*z$LoaderDefaultsTests.test_module_reprN)	r"r#r$rBr0rErbrerorrrrr_�sr_cseZdZ�fdd�Z�ZS)r/cst��|�SrD)rH�get_data�rrKrLrrrp�szResourceLoader.get_data)r"r#r$rprMrrrLrr/�sc@seZdZee�Zdd�ZdS)�ResourceLoaderDefaultsTestscCs:|�t��|j�d�Wd�n1s,0YdS)Nz
/some/path)rc�IOErrorrFrprrrr�
test_get_data�sz)ResourceLoaderDefaultsTests.test_get_dataN)r"r#r$rBr/rErtrrrrrr�srrcs(eZdZ�fdd�Z�fdd�Z�ZS)r1cst��|�SrD)rH�
is_packagerZrLrrruszInspectLoader.is_packagecst��|�SrD)rH�
get_sourcerZrLrrrvszInspectLoader.get_source)r"r#r$rurvrMrrrLrr1�sc@s eZdZeZdd�Zdd�ZdS)�InspectLoaderDefaultsTestscCs:|�t��|j�d�Wd�n1s,0YdSrf)rcrdrFrurrrr�test_is_packagesz*InspectLoaderDefaultsTests.test_is_packagecCs:|�t��|j�d�Wd�n1s,0YdSrf)rcrdrFrvrrrr�test_get_sourcesz*InspectLoaderDefaultsTests.test_get_sourceN)r"r#r$�SPLIT_ILrErxryrrrrrwsrwcseZdZ�fdd�Z�ZS)r3cst��|�SrD)rH�get_filenamerZrLrrr{szExecutionLoader.get_filename)r"r#r$r{rMrrrLrr3sc@seZdZeZdd�ZdS)�ExecutionLoaderDefaultsTestscCs:|�t��|j�d�Wd�n1s,0YdSrf)rcrdrFr{rrrr�test_get_filename*sz.ExecutionLoaderDefaultsTests.test_get_filenameN)r"r#r$�SPLIT_ELrEr}rrrrr|&sr|cs@eZdZ�fdd�Z�fdd�Z�fdd�Z�fdd�Z�ZS)	�ResourceReadercst�j|i|��SrD)rH�
open_resource�r�argsr@rLrrr�6szResourceReader.open_resourcecst�j|i|��SrD)rH�
resource_pathr�rLrrr�9szResourceReader.resource_pathcst�j|i|��SrD)rH�is_resourcer�rLrrr�<szResourceReader.is_resourcecst�j|i|��SrD)rH�contentsr�rLrrr�?szResourceReader.contents)r"r#r$r�r�r�r�rMrrrLrr4src@s4eZdZee�Zdd�Zdd�Zdd�Zdd�Z	d	S)
�ResourceReaderDefaultsTestscCs:|�t��|j�d�Wd�n1s,0YdS�NZ
dummy_file)rc�FileNotFoundErrorrFr�rrrr�test_open_resourceGsz.ResourceReaderDefaultsTests.test_open_resourcecCs:|�t��|j�d�Wd�n1s,0YdSr�)rcr�rFr�rrrr�test_resource_pathKsz.ResourceReaderDefaultsTests.test_resource_pathcCs:|�t��|j�d�Wd�n1s,0YdSr�)rcr�rFr�rrrr�test_is_resourceOsz,ResourceReaderDefaultsTests.test_is_resourcecCs|�gt|j����dSrD)r\�listrFr�rrrr�
test_contentsSsz)ResourceReaderDefaultsTests.test_contentsN)
r"r#r$rBrrEr�r�r�r�rrrrr�Cs
r�c@s8eZdZedd��Zdd�Zdd�Zdd�Zd	d
�ZdS)�MetaPathFinderFindModuleTestscsG�fdd�d|jj�}|�S)NcseZdZd�fdd�	ZdS)z@MetaPathFinderFindModuleTests.finder.<locals>.MetaPathSpecFinderNcs||f|_�SrD��
called_for)rrJrK�target�rarr�	find_specbs
zJMetaPathFinderFindModuleTests.finder.<locals>.MetaPathSpecFinder.find_spec)N�r"r#r$r�rr�rr�MetaPathSpecFinder`sr�)r
r&)r<rar�rr�r�finder^sz$MetaPathFinderFindModuleTests.findercCsZ|�d�}gd�}d}|�t��|�||�}Wd�n1sB0Y|�|�dS)N��a�b�crg)r�rPrQrIrR�rr�rKr9rTrrrrUhs
*z.MetaPathFinderFindModuleTests.test_find_modulecCs<t�}|j�d|�}|�|�}|�ddd�}|�||�dSrf)�objectr�spec_from_loaderr�r�r\�r�loaderrar�rTrrr�#test_find_spec_with_explicit_targetps

zAMetaPathFinderFindModuleTests.test_find_spec_with_explicit_targetcCsV|�d�}gd�}d}|�||d�}|�|�|�||jd�|�||jd�dS)Nr�rgrr)r�r�rRr\r�r�rrr�test_no_specws

z*MetaPathFinderFindModuleTests.test_no_speccCs:t�}|j�d|�}|�|�}|�dd�}|�||�dSrf)r�rr�r�r��assertIsr�rrr�	test_spec�s

z'MetaPathFinderFindModuleTests.test_specN)	r"r#r$�classmethodr�rUr�r�r�rrrrr�\s
		r�)r
rc@s0eZdZedd��Zdd�Zdd�Zdd�Zd	S)
�PathEntryFinderFindLoaderTestscsG�fdd�d|jj�}|�S)NcseZdZd�fdd�	ZdS)zBPathEntryFinderFindLoaderTests.finder.<locals>.PathEntrySpecFinderNcs
||_�SrDr�)rrJr�r�rrr��szLPathEntryFinderFindLoaderTests.finder.<locals>.PathEntrySpecFinder.find_spec)Nr�rr�rr�PathEntrySpecFinder�sr�)r
r-)r<rar�rr�rr��sz%PathEntryFinderFindLoaderTests.findercCsr|�d�}d}|�t��|�|�}Wd�n1s80Y|�|d�|�g|d�|�||j�dS)Nrgrr)r�rPrQrYrRr\r�)rr�r9rTrrrr��s
(z+PathEntryFinderFindLoaderTests.test_no_speccCsht�}|j�d|�}|�|�}|�t��|�d�}Wd�n1sH0Y|�|d|j�dS)Nrgr)	r�rr�r�rPrQrYr�r�r�rrr�test_spec_with_loader�s
(z4PathEntryFinderFindLoaderTests.test_spec_with_loadercCs||j�dd�}gd�}||_|�|�}|�t��|�d�}Wd�n1sP0Y|�|d�|�||d�dS)Nrgr�rr)	r�
ModuleSpec�submodule_search_locationsr�rPrQrYrRr\)rra�pathsr�rTrrr�test_spec_with_portions�s
(z6PathEntryFinderFindLoaderTests.test_spec_with_portionsN)r"r#r$r�r�r�r�r�rrrrr��s

		r�)r
rrc@s$eZdZdd�Zdd�Zdd�ZdS)�LoaderLoadModuleTestscCsGdd�d|jj�}|�S)Nc@s eZdZdZdd�Zdd�ZdS)z0LoaderLoadModuleTests.loader.<locals>.SpecLoaderNcSs
||_dSrD)rT�r�modulerrr�exec_module�sz<LoaderLoadModuleTests.loader.<locals>.SpecLoader.exec_modulecSsdS)z.Force some non-default module state to be set.TrrZrrrru�sz;LoaderLoadModuleTests.loader.<locals>.SpecLoader.is_package)r"r#r$rTr�rurrrr�
SpecLoader�sr�)r
r0)rr�rrrr��s	zLoaderLoadModuleTests.loadercCs�|��}d}t�|��2|�|�|j}|�tj||�Wd�n1sN0Y|�||j	�|�||j
j�|�||j�|�||j
j�|�
|j�|�
|j|j
j�dSrf)r�r?�uncacher^rTr��sys�modulesr\rm�__spec__r"r9ZassertIsNotNone�__path__r�)rr�r9r�rrr�
test_fresh�s
0�z LoaderLoadModuleTests.test_freshcCs�d}|��}t�|�}|j�||�|_||_t�|��N|t	j
|<|�|�|j}|�
|t	j
|�|�
|t	j
|�Wd�n1s�0YdSrf)r�rhrirr�r�rmr?r�r�r�r^rTr�)rr9r�r�rTrrr�test_reload�s


z!LoaderLoadModuleTests.test_reloadN)r"r#r$r�r�r�rrrrr��sr�c@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�InspectLoaderSourceToCodeTestsNcCsBt�d�}|��}|dur&|�|�}n|�||�}t||j�|S)z!Help with source_to_code() tests.rgN)rhri�InspectLoaderSubclass�source_to_code�exec�__dict__)r�datarKr�r��coderrr�source_to_module�s
z/InspectLoaderSourceToCodeTests.source_to_modulecCs0d}|�|�}|�t|d��|�|jd�dS)N�	attr = 42�attr�*�r�rrr\r��r�sourcer�rrr�test_source_to_code_source�s
z9InspectLoaderSourceToCodeTests.test_source_to_code_sourcecCs0d}|�|�}|�t|d��|�|jd�dS)Ns	attr = 42r�r�r�r�rrr�test_source_to_code_bytess
z8InspectLoaderSourceToCodeTests.test_source_to_code_bytescCs*d}|��}|�d|�}|�|j|�dS)Nzpath/to/somewhere��r�r�r\�co_filename)rrKr�r�rrr�test_source_to_code_path	sz7InspectLoaderSourceToCodeTests.test_source_to_code_pathcCs$|��}|�d�}|�|jd�dS)Nr��<string>r�)rr�r�rrr�test_source_to_code_no_paths
z:InspectLoaderSourceToCodeTests.test_source_to_code_no_path)N)r"r#r$r�r�r�r�r�rrrrr��s

r�)r�c@s$eZdZdd�Zdd�Zdd�ZdS)�InspectLoaderGetCodeTestscCspt�d�}tj�|jd��(}d|_|��}|�d�}Wd�n1sH0Yt||j	�|�
|jd�dS)Nrgrvr�r�)rhrir�patchr�r��return_value�get_coder�r�r\r�)rr��mockedr�r�rrr�
test_get_code s
(z'InspectLoaderGetCodeTests.test_get_codecCsVtj�|jd��(}d|_|��}|�d�}Wd�n1s>0Y|�|�dS)Nrvrg)rr�r�r�r�r�rR)rr�r�r�rrr�test_get_code_source_is_None*s
(z6InspectLoaderGetCodeTests.test_get_code_source_is_NonecCs@|��}|�t��|�d�Wd�n1s20YdSrf)r�rcrdr��rr�rrr�test_get_code_source_not_found2sz8InspectLoaderGetCodeTests.test_get_code_source_not_foundN)r"r#r$r�r�r�rrrrr�s
r�c@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�InspectLoaderLoadModuleTestsz!Test InspectLoader.load_module().rgcCs t�|j�|�tj|j�dSrD)rZunload�module_nameZ
addCleanuprrrrrEsz"InspectLoaderLoadModuleTests.setUpcCsV|j�|j|�}t���*t�dt�|jj�	|�Wd�S1sH0YdS�N�ignore)
rr�r��warnings�catch_warnings�simplefilterrQ�init�
_bootstrap�_load_unlocked)rr�rarrr�loadIs
z!InspectLoaderLoadModuleTests.loadcCstj�|jd�S)Nr�)rr�r�r�rrrr�
mock_get_codeOsz*InspectLoaderLoadModuleTests.mock_get_codec	Csn|���R}t|_|�t��"|��}|�|�Wd�n1sB0YWd�n1s`0YdSrD)r�rd�side_effectrcr�r��r�mocked_get_coder�rrr�test_get_code_ImportErrorRs

z6InspectLoaderLoadModuleTests.test_get_code_ImportErrorc	Csn|���R}d|_|�t��"|��}|�|�Wd�n1sB0YWd�n1s`0YdSrD)r�r�rcrdr�r�r�rrr�test_get_code_NoneZs

z/InspectLoaderLoadModuleTests.test_get_code_NonecCsdtddd�}|���<}||_|��}|�|�}|�|tj|j�Wd�n1sV0YdS)Nr�r�r�)	�compiler�r�r�r�r\r�r�r�)rr�r�r�r�rrr�test_module_returnedbs

z1InspectLoaderLoadModuleTests.test_module_returnedN)r"r#r$r%r�rr�r�r�r�r�rrrrr�?sr�)r�r�rc@s<eZdZddd�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ExecutionLoaderGetCodeTestsF�rvr{cCs8d\}}|rtj�|jd�}|r0tj�|jd�}||fS)N)NNrvr{)rr�r��ExecutionLoaderSubclass)rrvr{�source_mock_context�filename_mock_contextrrr�mock_methodsws
�
�z(ExecutionLoaderGetCodeTests.mock_methodsc		Cs�d}|jddd�\}}|�R}|�.}d|_||_|��}|�d�}Wd�n1sT0YWd�n1sr0Y|�|j|�t�d�}t||j	�|�|j
d�dS)Nzblah.pyTr�r�rgr�)r�r�r�r�r\r�rhrir�r�r�)	rrKr�r��source_mock�	name_mockr�r�r�rrrr��s�
F
z)ExecutionLoaderGetCodeTests.test_get_codecCsZ|jdd�\}}|�(}d|_|��}|�d�}Wd�n1sB0Y|�|�dS)NT)rvrg)r�r�r�r�rR)rr��_r�r�r�rrrr��s(z8ExecutionLoaderGetCodeTests.test_get_code_source_is_NonecCs@|��}|�t��|�d�Wd�n1s20YdSrf)r�rcrdr�r�rrrr��sz:ExecutionLoaderGetCodeTests.test_get_code_source_not_foundc	Cs�|jddd�\}}|�R}|�.}d|_t|_|��}|�d�}Wd�n1sP0YWd�n1sn0Y|�|jd�t�	d�}t
||j�|�|jd�dS)NTr�r�rgr�r�)
r�r�rdr�r�r�r\r�rhrir�r�r�)rr�r�r�r�r�r�r�rrr�test_get_code_no_path�s�
F
z1ExecutionLoaderGetCodeTests.test_get_code_no_pathN)r"r#r$r�r�r�r�r�rrrrr�us

	r�)r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�SourceOnlyLoadersN_ = '::'.join([__name__, __file__, __cached__, __package__, repr(__loader__)])cCs
||_dSrD�rKrqrrr�__init__�szSourceOnlyLoader.__init__cCs||jkrt�|jSrD)rKrsr�rqrrrrp�s
zSourceOnlyLoader.get_datacCs|jSrDr�rZrrrr{�szSourceOnlyLoader.get_filenamecCsdS)Nz<module>rr�rrrrk�szSourceOnlyLoader.module_reprN)r"r#r$r�r�rpr{rkrrrrr��s
r�cs>eZdZdZd�fdd�	Z�fdd�Zdd�Zd	d
�Z�ZS)r7rNcs�t��|�|j�|j�|_t|j�|_|dur8|jj	}t
|�}|�|j�
d��|�|j�
|j��|�|j�
|j��t|j|jddd�}|�t�|��t|�|_i|_dS)Nrr�T)�dont_inherit)rHr�r�cache_from_sourcerK�
bytecode_path�lenr��source_size�MAGIC_NUMBER�	bytearray�extendr��_pack_uint32�source_mtimer��marshal�dumps�bytes�bytecode�written)rrK�magicr��code_objectrLrrr��s�
zSourceLoader.__init__cs.||jkrt��|�S||jkr&|jSt�dSrD)rKrHrpr�r�OSErrorrqrLrrrp�s


zSourceLoader.get_datacCs||jkrt�|j|jd�S)N)�mtime�size)rKrsrr�rqrrr�
path_stats�s
zSourceLoader.path_statscCst|�|j|<||jkSrD)rrr�)rrKr�rrr�set_data�szSourceLoader.set_data)N)	r"r#r$rr�rprrrMrrrLrr7�s
)rr�c@s*eZdZdd�dd�Zdd�Zdd�Zd	S)
�SourceLoaderTestHarnessT�rucKs�d|_|r&tj�|jd�|_|j|_n2d}tj�|jd�ddg��|_d�|j|g�|_|j�|j�|_|j|jfi|��|_	dS)NZpkgz__init__.pyrn�.�py)
�package�osrK�joinr9rr��cached�loader_mockr�)rrur@r�rrrr�s
zSourceLoaderTestHarness.setUpcCs�|�|j|j�|�|j|j�|�|j|j�|�|j|j�|�|j	|j
�|j�d�}|�|d|j�|�|d|j�|�|d|j�|�|d|j�|�|dt
|j
��dS)Nz::rr���)r\r"r9�__file__rK�
__cached__r�__package__rrmr�r��splitrl)rr��valuesrrr�
verify_modulesz%SourceLoaderTestHarness.verify_modulecCsLt�|j�}|j|_|j|_|j|_|j	|_
g|_t||j
�|�|�dSrD)rhrir9rKrrrrrr�rmr�r�r�r)rrr�rrr�verify_codesz#SourceLoaderTestHarness.verify_codeN)r"r#r$rrrrrrrr
�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.

    cCs�|jj�d�}|�|j�|j�|�dd�}||j_|�t��}|j�|j�Wd�n1sb0Y|�|j	j|j�dS)N�utf-8cSst�dSrD)rr�rrr�
raise_OSError*sz<SourceOnlyLoaderTests.test_get_source.<locals>.raise_OSError)
r�r��decoder\rvr9rprcrdZ	exception)rZexpected_sourcer"�cmrrrry%s,z%SourceOnlyLoaderTests.test_get_sourcecCs\|jdd�|�|j�|j��|jdd�|�|j�|j��|�|j�|jd��dS)NFrTz	.__init__)r�assertFalser�rur9rrrrrrx1s
z%SourceOnlyLoaderTests.test_is_packagecCs|j�|j�}|�|�dSrD�r�r�r9r�rrrrrr�9sz#SourceOnlyLoaderTests.test_get_codecCs"|j�|jj|j�}|�|�dSrD)r�r�r�rKr)rr�rrr�test_source_to_code>sz)SourceOnlyLoaderTests.test_source_to_codec	Cs�t�|j���t���*t�dt�|j�|j�}Wd�n1sF0Y|�	|�|�
|jtj
�|j
�g�|�|jtj�Wd�n1s�0YdSr�)r?r�r9r�r�r�rQr�r^rr\r�rrK�dirname�assertInr�r�r�rrrreCs
,
z&SourceOnlyLoaderTests.test_load_modulec	Cs�|jdd�t�|j��lt���*t�dt�|j�	|j�}Wd�n1sR0Y|�
|�|�t|d��Wd�n1s�0YdS)NFrr�r�)
rr?r�r9r�r�r�rQr�r^rr%rr�rrr�test_package_settingsOs
,
z+SourceOnlyLoaderTests.test_package_settingscCs\d}|�d�|j_|j�|j�}|�||�d}|�d�|j_|j�|j�}|�||�dS)Nu_ = 'ü'r!u# coding: latin-1
_ = ü�latin-1)�encoder�r�rvr9r\)rr��returned_sourcerrr�test_get_source_encoding[sz.SourceOnlyLoaderTests.test_get_source_encodingN)r"r#r$r%ryrxr�r(rer+r/rrrrr sr )rrzsys.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��|�|r�|�|j|jj�t|jj�}|�	|j
�d��|�	|j
�|jj��|�	|j
�|jj
��|�	t�|��|�|jj|jt|��dS)Nr)rHrr*rr�rr�rr�r�r�r�rr�rrr\r)rrr2r�rLrrrwsz%SourceLoaderBytecodeTests.verify_codecCs|j�|j�}|�|�dSrDr&r'rrr�test_code_with_everything�sz3SourceLoaderBytecodeTests.test_code_with_everythingcCsld|j_|�t��*|j�|j�}|j�|�Wd�n1sB0Y|j�|j	�}|j
|dd�dS)N�<does not exist>Tr1)r�r�rcrrr�rKrpr�r9r)rr�rrrr�test_no_bytecode�s*z*SourceLoaderBytecodeTests.test_no_bytecodecCsfdD]\}||jjksJ�|jj}||j_|jjdd�|j_|j�|j�}|j|dd�||j_qdS)N)rr�Tr1)r�rrr�r9r)rrZoriginalrrrr�test_code_bad_timestamp�sz1SourceLoaderBytecodeTests.test_code_bad_timestampcCs@|jdd�|jjdd�|j_|j�|j�}|j|dd�dS)N�0000�rr6Tr1)rr�rr�r9rr'rrr�test_code_bad_magic�sz-SourceLoaderBytecodeTests.test_code_bad_magiccCsFz8dt_d|j_|j�|j�}|�|j|jj�Wdt_ndt_0dS)NTr4F)	r��dont_write_bytecoder�r�r�r9ZassertNotInrrr'rrr�test_dont_write_bytecode�sz2SourceLoaderBytecodeTests.test_dont_write_bytecodec	Csv|jdd�|jj��dj}z>|jj��d`|j�|j�}|�|�W||jj��d_n||jj��d_0dS)Nr8r9r)rr�r�mrorr�r9r)rZoriginal_set_datarrrr�test_no_set_data�sz*SourceLoaderBytecodeTests.test_no_set_datacCs<dd�}|jdd�|t�|j_|j�|j�}|�|�dS)Ncs�fdd�}|S)Ncs��dSrDr)r�r@��excrr�closure�szcSourceLoaderBytecodeTests.test_set_data_raises_exceptions.<locals>.raise_exception.<locals>.closurer)r@rArr?r�raise_exception�szRSourceLoaderBytecodeTests.test_set_data_raises_exceptions.<locals>.raise_exceptionr8r9)rrjr�rr�r9r)rrBrrrr�test_set_data_raises_exceptions�s
z9SourceLoaderBytecodeTests.test_set_data_raises_exceptions)
r"r#r$r%rr3r5r7r:r<r>rCrMrrrLrr0ns
r0)r�rrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SourceLoaderGetSourceTestsz2Tests for importlib.abc.SourceLoader.get_source().cCs8d}|�d�}d}|�d�|_|�|�}|�||�dS)Nrn�mod.fileux = "ü"r!��SourceOnlyLoaderMockr-r�rvr\�rr9rr�r.rrr�test_default_encoding�s

z0SourceLoaderGetSourceTests.test_default_encodingcCsPd}|�d�}d}|�d�|�d�ks*J�|�d�|_|�|�}|�||�dS)NrnrEu# coding: Latin-1
x='ü'r,r!rFrHrrr�test_decoded_source�s

z.SourceLoaderGetSourceTests.test_decoded_sourcecCsFd}|�d�}d}|�d�|_t�dd��|�}|�|�|�|�dS)NrnrEzx = 42
y = -13
r!T)rGr-r��io�IncrementalNewlineDecoderr#r\rv)rr9rr�Zexpectrrr�test_universal_newlines�s
z2SourceLoaderGetSourceTests.test_universal_newlinesN)r"r#r$r%rIrJrMrrrrrD�s	
rD)rG�__main__)NF)irKrrr��testrrhZunittestrr�r�rr?Zimport_importlibr�r
rrr&Z	test_bothZ%Frozen_MetaPathFinderInheritanceTestsZ%Source_MetaPathFinderInheritanceTestsr-Z&Frozen_PathEntryFinderInheritanceTestsZ&Source_PathEntryFinderInheritanceTestsr/Z%Frozen_ResourceLoaderInheritanceTestsZ%Source_ResourceLoaderInheritanceTestsr1Z$Frozen_InspectLoaderInheritanceTestsZ$Source_InspectLoaderInheritanceTestsr3Z&Frozen_ExecutionLoaderInheritanceTestsZ&Source_ExecutionLoaderInheritanceTestsr4Z!Frozen_FileLoaderInheritanceTestsZ!Source_FileLoaderInheritanceTestsr7Z#Frozen_SourceLoaderInheritanceTestsZ#Source_SourceLoaderInheritanceTestsrBrCrNZFrozen_MPFDefaultTestsZSource_MPFDefaultTestsr[ZFrozen_PEFDefaultTestsZSource_PEFDefaultTestsr0r_ZFrozen_LDefaultTestsZSourceLDefaultTestsrrZFrozen_RLDefaultTestsZSource_RLDefaultTestsrzrwZFrozen_ILDefaultTestsZSource_ILDefaultTestsr~r|ZFrozen_ELDefaultTestsZSource_ELDefaultsTestsrr�ZFrozen_RRDefaultTestsZSource_RRDefaultsTestsr�ZFrozen_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_SourceOnlyLoaderTestsZskipIfr;r0ZFrozen_SLBytecodeTestsZSourceSLBytecodeTestsrDZ%Frozen_SourceOnlyLoaderGetSourceTestsZ%Source_SourceOnlyLoaderGetSourceTestsr"�mainrrrr�<module>s&



$�������
	����	���.�*
��-�,����/��;��
&&N��[
��#��