Your IP : 216.73.216.213


Current Path : /opt/alt/python38/lib64/python3.8/test/test_importlib/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/test/test_importlib/__pycache__/test_abc.cpython-38.pyc

U

i�fC��@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�jsTt�j��t	�j�j
��_dS)Ncsg|]}t�j|��qS�)�getattr�abc��.0�
class_name��selfr�A/opt/alt/python38/lib64/python3.8/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�AssertionError�	__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@seZdZdgZddddgZdS)�MetaPathFinder�Finder�BuiltinImporter�FrozenImporter�
PathFinder�WindowsRegistryFinderN�r#r$r%rrrrrrr'8s�r')r
c@seZdZdgZdgZdS)�PathEntryFinderr(�
FileFinderNr-rrrrr.Csr.c@seZdZdgZdS)�ResourceLoader�LoaderN)r#r$r%rrrrrr0Msr0c@seZdZdgZdddgZdS)�
InspectLoaderr1r)r*�ExtensionFileLoaderNr-rrrrr2Vsr2c@seZdZdgZdgZdS)�ExecutionLoaderr2r3Nr-rrrrr4`sr4c@seZdZddgZddgZdS)�
FileLoaderr0r4�SourceFileLoader�SourcelessFileLoaderNr-rrrrr5jsr5c@seZdZddgZdgZdS)�SourceLoaderr0r4r6Nr-rrrrr8tsr8FcsB�dkr|j��fdd�t��D�}�fdd�tj||f|�D�S)Ncsi|]\}}|t|���qSrr)rZkindZsplitabc)�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)�MetaPathFinderDefaultsTestsc	Cs2|�t��|j�dd�}W5QRX|�|�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)�PathEntryFinderDefaultsTestsc	Cs6|�t��|j�d�}W5QRX|�|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)r1cst��|�SrD)rH�load_modulerZrLrrr^�szLoader.load_module)r#r$r%r^rMrrrLrr1�sr1c@s,eZdZee�Zdd�Zdd�Zdd�ZdS)�LoaderDefaultsTestscCsd}|�|j�|��dS)Nza spec)rRrF�
create_module)r�specrrr�test_create_module�sz&LoaderDefaultsTests.test_create_modulec	Cs&|�t��|j�d�W5QRXdSrO)�assertRaises�ImportErrorrFr^rrrr�test_load_module�sz$LoaderDefaultsTests.test_load_modulec	CsNt�d�}|�t��|j�|�W5QRXt|�}|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%rBr1rErbrerorrrrr_�sr_cseZdZ�fdd�Z�ZS)r0cst��|�SrD)rH�get_data�rrKrLrrrp�szResourceLoader.get_data)r#r$r%rprMrrrLrr0�sc@seZdZee�Zdd�ZdS)�ResourceLoaderDefaultsTestsc	Cs&|�t��|j�d�W5QRXdS)Nz
/some/path)rc�IOErrorrFrprrrr�
test_get_data�sz)ResourceLoaderDefaultsTests.test_get_dataN)r#r$r%rBr0rErtrrrrrr�srrcs(eZdZ�fdd�Z�fdd�Z�ZS)r2cst��|�SrD)rH�
is_packagerZrLrrruszInspectLoader.is_packagecst��|�SrD)rH�
get_sourcerZrLrrrvszInspectLoader.get_source)r#r$r%rurvrMrrrLrr2�sc@s eZdZeZdd�Zdd�ZdS)�InspectLoaderDefaultsTestsc	Cs&|�t��|j�d�W5QRXdSrf)rcrdrFrurrrr�test_is_packagesz*InspectLoaderDefaultsTests.test_is_packagec	Cs&|�t��|j�d�W5QRXdSrf)rcrdrFrvrrrr�test_get_sourcesz*InspectLoaderDefaultsTests.test_get_sourceN)r#r$r%�SPLIT_ILrErxryrrrrrwsrwcseZdZ�fdd�Z�ZS)r4cst��|�SrD)rH�get_filenamerZrLrrr{szExecutionLoader.get_filename)r#r$r%r{rMrrrLrr4sc@seZdZeZdd�ZdS)�ExecutionLoaderDefaultsTestsc	Cs&|�t��|j�d�W5QRXdSrf)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||�SrD)rH�
open_resource�r�argsr@rLrrr�6szResourceReader.open_resourcecst�j||�SrD)rH�
resource_pathr�rLrrr�9szResourceReader.resource_pathcst�j||�SrD)rH�is_resourcer�rLrrr�<szResourceReader.is_resourcecst�j||�SrD)rH�contentsr�rLrrr�?szResourceReader.contents)r#r$r%r�r�r�r�rMrrrLrr4src@s4eZdZee�Zdd�Zdd�Zdd�Zdd�Z	d	S)
�ResourceReaderDefaultsTestsc	Cs&|�t��|j�d�W5QRXdS�NZ
dummy_file)rc�FileNotFoundErrorrFr�rrrr�test_open_resourceGsz.ResourceReaderDefaultsTests.test_open_resourcec	Cs&|�t��|j�d�W5QRXdSr�)rcr�rFr�rrrr�test_resource_pathKsz.ResourceReaderDefaultsTests.test_resource_pathc	Cs&|�t��|j�d�W5QRXdSr�)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@s(eZdZedd��Zdd�Zdd�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.finderc	Csl|�d�}dddg}d}|�t��|�||�}W5QRX|�|�|�||jd�|�||jd�dS)N�a�b�crgrr)r�rPrQrIrRr\r�)rr�rKr9rTrrr�test_no_spechs


z*MetaPathFinderFindModuleTests.test_no_specc	CsRt�}|j�d|�}|�|�}|�t��|�dd�}W5QRX|�||j�dSrf)	�objectr�spec_from_loaderr�rPrQrI�assertIs�loader�rr�rar�rTrrr�	test_specrs
z'MetaPathFinderFindModuleTests.test_specN)r#r$r%�classmethodr�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.finderc	Cs^|�d�}d}|�t��|�|�}W5QRX|�|d�|�g|d�|�||j�dS)Nrgrr)r�rPrQrYrRr\r�)rr�r9rTrrrr��s
z+PathEntryFinderFindLoaderTests.test_no_specc	CsTt�}|j�d|�}|�|�}|�t��|�d�}W5QRX|�|d|j�dS)Nrgr)	r�rr�r�rPrQrYr�r�r�rrr�test_spec_with_loader�s
z4PathEntryFinderFindLoaderTests.test_spec_with_loaderc	Csj|j�dd�}dddg}||_|�|�}|�t��|�d�}W5QRX|�|d�|�||d�dS)Nrgr�r�r�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
r1)rr�rrrr��s	zLoaderLoadModuleTests.loaderc	Cs�|��}d}t�|��(|�|�|j}|�tj||�W5QRX|�||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
�z LoaderLoadModuleTests.test_freshc	Cs�d}|��}t�|�}|j�||�|_||_t�|��D|t	j
|<|�|�|j}|�
|t	j
|�|�
|t	j
|�W5QRXdSrf)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�}|��}|dkr&|�|�}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_bytes�s
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)�InspectLoaderGetCodeTestsc	Cs\t�d�}tj�|jd��}d|_|��}|�d�}W5QRXt||j	�|�
|jd�dS)Nrgrvr�r�)rhrir�patchr�r��return_value�get_coder�r�r\r�)rr��mockedr�r�rrr�
test_get_codes
z'InspectLoaderGetCodeTests.test_get_codec	CsBtj�|jd��}d|_|��}|�d�}W5QRX|�|�dS)Nrvrg)rr�r�r�r�r�rR)rr�r�r�rrr�test_get_code_source_is_Nones
z6InspectLoaderGetCodeTests.test_get_code_source_is_Nonec	Cs,|��}|�t��|�d�W5QRXdSrf)r�rcrdr��rr�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@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
addCleanuprrrrr8sz"InspectLoaderLoadModuleTests.setUpc
CsJ|j�|j|�}t���(t�dt�|jj�	|�W5QR�SQRXdS�N�ignore)
rr�r��warnings�catch_warnings�simplefilterrQ�init�
_bootstrap�_load_unlocked)rr�rarrr�load<s
z!InspectLoaderLoadModuleTests.loadcCstj�|jd�S)Nr�)rr�r�r�rrrr�
mock_get_codeBsz*InspectLoaderLoadModuleTests.mock_get_codec
CsF|���4}t|_|�t��|��}|�|�W5QRXW5QRXdSrD)r�rd�side_effectrcr�r��r�mocked_get_coder�rrr�test_get_code_ImportErrorEs

z6InspectLoaderLoadModuleTests.test_get_code_ImportErrorc
CsF|���4}d|_|�t��|��}|�|�W5QRXW5QRXdSrD)r�r�rcrdr�r�r�rrr�test_get_code_NoneMs

z/InspectLoaderLoadModuleTests.test_get_code_Nonec	CsPtddd�}|���2}||_|��}|�|�}|�|tj|j�W5QRXdS)Nr�r�r�)	�compiler�r�r�r�r\r�r�r�)rr�r�r�r�rrr�test_module_returnedUs

z1InspectLoaderLoadModuleTests.test_module_returnedN)r#r$r%r&r�rr�r�r�r�r�rrrrr�2sr�)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_methodsjs
�
�z(ExecutionLoaderGetCodeTests.mock_methodsc	
Cs�d}|jddd�\}}|�4}|�$}d|_||_|��}|�d�}W5QRXW5QRX|�|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�ts�

z)ExecutionLoaderGetCodeTests.test_get_codec	CsF|jdd�\}}|�}d|_|��}|�d�}W5QRX|�|�dS)NT)rvrg)r�r�r�r�rR)rr��_r�r�r�rrrr��sz8ExecutionLoaderGetCodeTests.test_get_code_source_is_Nonec	Cs,|��}|�t��|�d�W5QRXdSrf)r�rcrdr�r�rrrr��sz:ExecutionLoaderGetCodeTests.test_get_code_source_not_foundc
Cs�|jddd�\}}|�4}|�$}d|_t|_|��}|�d�}W5QRXW5QRX|�|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�

z1ExecutionLoaderGetCodeTests.test_get_code_no_pathN)r#r$r%r�r�r�r�r�rrrrr�hs

	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)r8rNcs�t��|�|j�|j�|_t|j�|_|dkr8|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)rKrsr�r�rqrrr�
path_stats�s
zSourceLoader.path_statscCst|�|j|<||jkSrD)rrr�)rrKr�rrr�set_data�szSourceLoader.set_data)N)	r#r$r%r�r�rprr	rMrrrLrr8�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|jf|�|_	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_module�s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.

    c	Csn|jj�d�}|�|j�|j�|�dd�}||j_|�t��}|j�|j�W5QRX|�|j	j|j�dS)N�utf-8cSst�dSrD)rr�rrr�
raise_OSErrorsz<SourceOnlyLoaderTests.test_get_source.<locals>.raise_OSError)
r�r��decoder\rvr9rprcrdZ	exception)rZexpected_sourcer�cmrrrrysz%SourceOnlyLoaderTests.test_get_sourcecCs\|jdd�|�|j�|j��|jdd�|�|j�|j��|�|j�|jd��dS)NFrTz	.__init__)r�assertFalser�rur9rrrrrrx$s
z%SourceOnlyLoaderTests.test_is_packagecCs|j�|j�}|�|�dSrD�r�r�r9r�rrrrrr�,sz#SourceOnlyLoaderTests.test_get_codecCs"|j�|jj|j�}|�|�dSrD)r�r�r�rKr)rr�rrr�test_source_to_code1sz)SourceOnlyLoaderTests.test_source_to_codec
Cs~t�|j��ht��� t�dt�|j�|j�}W5QRX|�	|�|�
|jtj
�|j
�g�|�|jtj�W5QRXdSr�)r?r�r9r�r�r�rQr�r^rr\r�rrK�dirname�assertInr�r�r�rrrre6s

z&SourceOnlyLoaderTests.test_load_modulec
Csp|jdd�t�|j��Nt��� t�dt�|j�	|j�}W5QRX|�
|�|�t|d��W5QRXdS)NFrr�r�)
rr?r�r9r�r�r�rQr�r^rr"rr�rrr�test_package_settingsBs

z+SourceOnlyLoaderTests.test_package_settingscCs\d}|�d�|j_|j�|j�}|�||�d}|�d�|j_|j�|j�}|�||�dS)Nu_ = 'ü'ru# coding: latin-1
_ = ü�latin-1)�encoder�r�rvr9r\)rr��returned_sourcerrr�test_get_source_encodingNsz.SourceOnlyLoaderTests.test_get_source_encodingN)r#r$r%r&ryrxr�r%rer(r,rrrrrs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�r�r�r�r�r\r)rrr/r�rLrrrjsz%SourceLoaderBytecodeTests.verify_codecCs|j�|j�}|�|�dSrDr#r$rrr�test_code_with_everythingusz3SourceLoaderBytecodeTests.test_code_with_everythingc	CsXd|j_|�t�� |j�|j�}|j�|�W5QRX|j�|j	�}|j
|dd�dS)N�<does not exist>Tr.)r�r�rcrrr�rKrpr�r9r)rr�rrrr�test_no_bytecodezsz*SourceLoaderBytecodeTests.test_no_bytecodecCsfdD]\}||jjkst�|jj}||j_|jjdd�|j_|j�|j�}|j|dd�||j_qdS)N)rr�Tr.)r�r�rrr�r9r)rr�Zoriginalrrrr�test_code_bad_timestamp�sz1SourceLoaderBytecodeTests.test_code_bad_timestampcCs@|jdd�|jjdd�|j_|j�|j�}|j|dd�dS)N�0000�rr3Tr.)rr�rr�r9rr$rrr�test_code_bad_magic�sz-SourceLoaderBytecodeTests.test_code_bad_magiccCs@z2dt_d|j_|j�|j�}|�|j|jj�W5dt_XdS)NFTr1)	r��dont_write_bytecoder�r�r�r9ZassertNotInrrr$rrr�test_dont_write_bytecode�sz2SourceLoaderBytecodeTests.test_dont_write_bytecodec	Csd|jdd�|jj��dj}z,|jj��d`|j�|j�}|�|�W5||jj��d_XdS)Nr5r6r)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=r>rr<r�raise_exception�szRSourceLoaderBytecodeTests.test_set_data_raises_exceptions.<locals>.raise_exceptionr5r6)rrjr�r	r�r9r)rr?rrrr�test_set_data_raises_exceptions�s
z9SourceLoaderBytecodeTests.test_set_data_raises_exceptions)
r#r$r%r&rr0r2r4r7r9r;r@rMrrrLrr-as
r-)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*t�|�d�|_|�|�}|�||�dS)NrnrBu# coding: Latin-1
x='ü'r)r)rCr*rr�rvr\rDrrr�test_decoded_source�s

z.SourceLoaderGetSourceTests.test_decoded_sourcecCsFd}|�d�}d}|�d�|_t�dd��|�}|�|�|�|�dS)NrnrBzx = 42
y = -13
rT)rCr*r��io�IncrementalNewlineDecoderr r\rv)rr9rr�Zexpectrrr�test_universal_newlines�s
z2SourceLoaderGetSourceTests.test_universal_newlinesN)r#r$r%r&rErFrIrrrrrA�s	
rA)rC�__main__)NF)irGr�rr�ZtestrrhZunittestrr�r�rr?Zimport_importlibr�r
rrr'Z	test_bothZ%Frozen_MetaPathFinderInheritanceTestsZ%Source_MetaPathFinderInheritanceTestsr.Z&Frozen_PathEntryFinderInheritanceTestsZ&Source_PathEntryFinderInheritanceTestsr0Z%Frozen_ResourceLoaderInheritanceTestsZ%Source_ResourceLoaderInheritanceTestsr2Z$Frozen_InspectLoaderInheritanceTestsZ$Source_InspectLoaderInheritanceTestsr4Z&Frozen_ExecutionLoaderInheritanceTestsZ&Source_ExecutionLoaderInheritanceTestsr5Z!Frozen_FileLoaderInheritanceTestsZ!Source_FileLoaderInheritanceTestsr8Z#Frozen_SourceLoaderInheritanceTestsZ#Source_SourceLoaderInheritanceTestsrBrCrNZFrozen_MPFDefaultTestsZSource_MPFDefaultTestsr[ZFrozen_PEFDefaultTestsZSource_PEFDefaultTestsr1r_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
rZFrozen_SourceOnlyLoaderTestsZSource_SourceOnlyLoaderTestsZskipIfr8r-ZFrozen_SLBytecodeTestsZSourceSLBytecodeTestsrAZ%Frozen_SourceOnlyLoaderGetSourceTestsZ%Source_SourceOnlyLoaderGetSourceTestsr#�mainrrrr�<module>s&



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