HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/test/test_importlib/__pycache__/test_abc.cpython-38.pyc
U

/D�gC��@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�;/opt/cppython/lib/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�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_classr:r>�kwargs�baser)r>r:r�make_abc_subclasses�s
�
�rCc@seZdZedd��ZdS)�ABCTestHarnesscCs|j|j}|�}||j_|S�N)�SPLITr<r�ins)rr=rGrrrrG�szABCTestHarness.insN)r#r$r%�propertyrGrrrrrD�srDcseZdZ�fdd�Z�ZS)r'cst��||�SrE)�super�find_module)r�fullname�path�rrrrJ�szMetaPathFinder.find_module)r#r$r%rJ�
__classcell__rrrMrr'�sc@s$eZdZee�Zdd�Zdd�ZdS)�MetaPathFinderDefaultsTestsc	Cs2|�t��|j�dd�}W5QRX|�|�dS�NZ	something)�assertWarns�DeprecationWarningrGrJ�assertIsNone�r�foundrrr�test_find_module�sz,MetaPathFinderDefaultsTests.test_find_modulecCs|j��dSrE�rG�invalidate_cachesrrrr�test_invalidate_caches�sz2MetaPathFinderDefaultsTests.test_invalidate_cachesN)r#r$r%rCr'rFrVrYrrrrrO�srOcseZdZ�fdd�Z�ZS)r.cst��|�SrE)rI�find_loader�rrKrMrrrZ�szPathEntryFinder.find_loader)r#r$r%rZrNrrrMrr.�sc@s,eZdZee�Zdd�Zdd�Zdd�ZdS)�PathEntryFinderDefaultsTestsc	Cs6|�t��|j�d�}W5QRX|�|dgf�dSrP)rQrRrGrZ�assertEqualrTrrr�test_find_loader�sz-PathEntryFinderDefaultsTests.test_find_loadercCs|�d|j�d��dSrP)r]rGrJrrrrrJ�sz(PathEntryFinderDefaultsTests.find_modulecCs|j��dSrErWrrrrrY�sz3PathEntryFinderDefaultsTests.test_invalidate_cachesN)	r#r$r%rCr.rFr^rJrYrrrrr\�sr\cseZdZ�fdd�Z�ZS)r1cst��|�SrE)rI�load_moduler[rMrrr_�szLoader.load_module)r#r$r%r_rNrrrMrr1�sr1c@s,eZdZee�Zdd�Zdd�Zdd�ZdS)�LoaderDefaultsTestscCsd}|�|j�|��dS)Nza spec)rSrG�
create_module)r�specrrr�test_create_module�sz&LoaderDefaultsTests.test_create_modulec	Cs&|�t��|j�d�W5QRXdSrP)�assertRaises�ImportErrorrGr_rrrr�test_load_module�sz$LoaderDefaultsTests.test_load_modulec	CsNt�d�}|�t��|j�|�W5QRXt|�}|j|_|�t|��dS�N�blah)	�types�
ModuleTyperd�NotImplementedErrorrG�module_repr�repr�
__loader__r)r�modZ
original_reprrrr�test_module_repr�s
z$LoaderDefaultsTests.test_module_reprN)	r#r$r%rCr1rFrcrfrprrrrr`�sr`cseZdZ�fdd�Z�ZS)r0cst��|�SrE)rI�get_data�rrLrMrrrq�szResourceLoader.get_data)r#r$r%rqrNrrrMrr0�sc@seZdZee�Zdd�ZdS)�ResourceLoaderDefaultsTestsc	Cs&|�t��|j�d�W5QRXdS)Nz
/some/path)rd�IOErrorrGrqrrrr�
test_get_data�sz)ResourceLoaderDefaultsTests.test_get_dataN)r#r$r%rCr0rFrurrrrrs�srscs(eZdZ�fdd�Z�fdd�Z�ZS)r2cst��|�SrE)rI�
is_packager[rMrrrvszInspectLoader.is_packagecst��|�SrE)rI�
get_sourcer[rMrrrwszInspectLoader.get_source)r#r$r%rvrwrNrrrMrr2�sc@s eZdZeZdd�Zdd�ZdS)�InspectLoaderDefaultsTestsc	Cs&|�t��|j�d�W5QRXdSrg)rdrerGrvrrrr�test_is_packagesz*InspectLoaderDefaultsTests.test_is_packagec	Cs&|�t��|j�d�W5QRXdSrg)rdrerGrwrrrr�test_get_sourcesz*InspectLoaderDefaultsTests.test_get_sourceN)r#r$r%�SPLIT_ILrFryrzrrrrrxsrxcseZdZ�fdd�Z�ZS)r4cst��|�SrE)rI�get_filenamer[rMrrr|szExecutionLoader.get_filename)r#r$r%r|rNrrrMrr4sc@seZdZeZdd�ZdS)�ExecutionLoaderDefaultsTestsc	Cs&|�t��|j�d�W5QRXdSrg)rdrerGr|rrrr�test_get_filename*sz.ExecutionLoaderDefaultsTests.test_get_filenameN)r#r$r%�SPLIT_ELrFr~rrrrr}&sr}cs@eZdZ�fdd�Z�fdd�Z�fdd�Z�fdd�Z�ZS)	�ResourceReadercst�j||�SrE)rI�
open_resource�r�argsrArMrrr�6szResourceReader.open_resourcecst�j||�SrE)rI�
resource_pathr�rMrrr�9szResourceReader.resource_pathcst�j||�SrE)rI�is_resourcer�rMrrr�<szResourceReader.is_resourcecst�j||�SrE)rI�contentsr�rMrrr�?szResourceReader.contents)r#r$r%r�r�r�r�rNrrrMrr�4sr�c@s4eZdZee�Zdd�Zdd�Zdd�Zdd�Z	d	S)
�ResourceReaderDefaultsTestsc	Cs&|�t��|j�d�W5QRXdS�NZ
dummy_file)rd�FileNotFoundErrorrGr�rrrr�test_open_resourceGsz.ResourceReaderDefaultsTests.test_open_resourcec	Cs&|�t��|j�d�W5QRXdSr�)rdr�rGr�rrrr�test_resource_pathKsz.ResourceReaderDefaultsTests.test_resource_pathc	Cs&|�t��|j�d�W5QRXdSr�)rdr�rGr�rrrr�test_is_resourceOsz,ResourceReaderDefaultsTests.test_is_resourcecCs|�gt|j����dSrE)r]�listrGr�rrrr�
test_contentsSsz)ResourceReaderDefaultsTests.test_contentsN)
r#r$r%rCr�rFr�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|_�SrE��
called_for)rrKrL�target�rbrr�	find_specbs
zJMetaPathFinderFindModuleTests.finder.<locals>.MetaPathSpecFinder.find_spec)N�r#r$r%r�rr�rr�MetaPathSpecFinder`sr�)r
r')r=rbr�rr�r�finder^sz$MetaPathFinderFindModuleTests.finderc	Csl|�d�}dddg}d}|�t��|�||�}W5QRX|�|�|�||jd�|�||jd�dS)N�a�b�crhrr)r�rQrRrJrSr]r�)rr�rLr:rUrrr�test_no_spechs


z*MetaPathFinderFindModuleTests.test_no_specc	CsRt�}|j�d|�}|�|�}|�t��|�dd�}W5QRX|�||j�dSrg)	�objectr�spec_from_loaderr�rQrRrJ�assertIs�loader�rr�rbr�rUrrr�	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
||_�SrEr�)rrKr�r�rrr��szLPathEntryFinderFindLoaderTests.finder.<locals>.PathEntrySpecFinder.find_spec)Nr�rr�rr�PathEntrySpecFinder�sr�)r
r.)r=rbr�rr�rr��sz%PathEntryFinderFindLoaderTests.finderc	Cs^|�d�}d}|�t��|�|�}W5QRX|�|d�|�g|d�|�||j�dS)Nrhrr)r�rQrRrZrSr]r�)rr�r:rUrrrr��s
z+PathEntryFinderFindLoaderTests.test_no_specc	CsTt�}|j�d|�}|�|�}|�t��|�d�}W5QRX|�|d|j�dS)Nrhr)	r�rr�r�rQrRrZr�r�r�rrr�test_spec_with_loader�s
z4PathEntryFinderFindLoaderTests.test_spec_with_loaderc	Csj|j�dd�}dddg}||_|�|�}|�t��|�d�}W5QRX|�|d�|�||d�dS)Nrhr�r�r�rr)	r�
ModuleSpec�submodule_search_locationsr�rQrRrZrSr])rrb�pathsr�rUrrr�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
||_dSrE)rU�r�modulerrr�exec_module�sz<LoaderLoadModuleTests.loader.<locals>.SpecLoader.exec_modulecSsdS)z.Force some non-default module state to be set.Trr[rrrrv�sz;LoaderLoadModuleTests.loader.<locals>.SpecLoader.is_package)r#r$r%rUr�rvrrrr�
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�dSrg)r�r@�uncacher_rUr��sys�modulesr]rn�__spec__r#r:ZassertIsNotNone�__path__r�)rr�r:r�rrr�
test_fresh�s
�z LoaderLoadModuleTests.test_freshc	Cs�d}|��}t�|�}|j�||�|_||_t�|��D|t	j
|<|�|�|j}|�
|t	j
|�|�
|t	j
|�W5QRXdSrg)r�rirjrr�r�rnr@r�r�r�r_rUr�)rr:r�r�rUrrr�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.rhN)rirj�InspectLoaderSubclass�source_to_code�exec�__dict__)r�datarLr�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)rrLr�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)Nrhrwr�r�)rirjr�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)Nrwrh)rr�r�r�r�r�rS)rr�r�r�rrr�test_get_code_source_is_Nones
z6InspectLoaderGetCodeTests.test_get_code_source_is_Nonec	Cs,|��}|�t��|�d�W5QRXdSrg)r�rdrer��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().rhcCs t�|j�|�tj|j�dSrE)rZunload�module_nameZ
addCleanuprrrrr8sz"InspectLoaderLoadModuleTests.setUpc
CsJ|j�|j|�}t���(t�dt�|jj�	|�W5QR�SQRXdS�N�ignore)
rr�r��warnings�catch_warnings�simplefilterrR�init�
_bootstrap�_load_unlocked)rr�rbrrr�load<s
z!InspectLoaderLoadModuleTests.loadcCstj�|jd�S)Nr�)rr�r�r�rrrr�
mock_get_codeBsz*InspectLoaderLoadModuleTests.mock_get_codec
CsF|���4}t|_|�t��|��}|�|�W5QRXW5QRXdSrE)r�re�side_effectrdr�r��r�mocked_get_coder�rrr�test_get_code_ImportErrorEs

z6InspectLoaderLoadModuleTests.test_get_code_ImportErrorc
CsF|���4}d|_|�t��|��}|�|�W5QRXW5QRXdSrE)r�r�rdrer�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�rwr|cCs8d\}}|rtj�|jd�}|r0tj�|jd�}||fS)N)NNrwr|)rr�r��ExecutionLoaderSubclass)rrwr|�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�rhr�)r�r�r�r�r]r�rirjr�r�r�)	rrLr�r��source_mock�	name_mockr�r�r�rrrr�ts�

z)ExecutionLoaderGetCodeTests.test_get_codec	CsF|jdd�\}}|�}d|_|��}|�d�}W5QRX|�|�dS)NT)rwrh)r�r�r�r�rS)rr��_r�r�r�rrrr��sz8ExecutionLoaderGetCodeTests.test_get_code_source_is_Nonec	Cs,|��}|�t��|�d�W5QRXdSrg)r�rdrer�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�rhr�r�)
r�r�rer�r�r�r]r�rirjr�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
||_dSrE�rLrrrrr�__init__�szSourceOnlyLoader.__init__cCs||jkrt�|jSrE)rLrtr�rrrrrrq�s
zSourceOnlyLoader.get_datacCs|jSrEr�r[rrrr|�szSourceOnlyLoader.get_filenamecCsdS)Nz<module>rr�rrrrl�szSourceOnlyLoader.module_reprN)r#r$r%r�r�rqr|rlrrrrr��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)rIr�r�cache_from_sourcerL�
bytecode_path�lenr��source_size�MAGIC_NUMBER�	bytearray�extendr��_pack_uint32�source_mtimer��marshal�dumps�bytes�bytecode�written)rrL�magicr��code_objectrMrrr��s�
zSourceLoader.__init__cs.||jkrt��|�S||jkr&|jSt�dSrE)rLrIrqr�r�OSErrorrrrMrrrq�s


zSourceLoader.get_datacCs||jkrt�|j|jd�S)N)�mtime�size)rLrtr�r�rrrrr�
path_stats�s
zSourceLoader.path_statscCst|�|j|<||jkSrE)rrr�)rrLr�rrr�set_data�szSourceLoader.set_data)N)	r#r$r%r�r�rqr	r
rNrrrMrr8�s
)rr�c@s*eZdZdd�dd�Zdd�Zdd�Zd	S)
�SourceLoaderTestHarnessT�rvcKs~d|_|r&tj�|jd�|_|j|_n2d}tj�|jd�ddg��|_d�|j|g�|_|j�|j�|_|j|jf|�|_	dS)NZpkgz__init__.pyro�.�py)
�package�osrL�joinr:rr��cached�loader_mockr�)rrvrAr�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#r:�__file__rL�
__cached__r�__package__rrnr�r��splitrm)rr��valuesrrr�
verify_module�sz%SourceLoaderTestHarness.verify_modulecCsLt�|j�}|j|_|j|_|j|_|j	|_
g|_t||j
�|�|�dSrE)rirjr:rLrrrrrr�rnr�r�r�r)rrr�rrr�verify_codesz#SourceLoaderTestHarness.verify_codeN)r#r$r%rrrrrrrr�s
rc@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�dSrE)rr�rrr�
raise_OSErrorsz<SourceOnlyLoaderTests.test_get_source.<locals>.raise_OSError)
r�r��decoder]rwr:rqrdre�	exception)rZexpected_sourcer �cmrrrrzsz%SourceOnlyLoaderTests.test_get_sourcecCs\|jdd�|�|j�|j��|jdd�|�|j�|j��|�|j�|jd��dS)NFrTz	.__init__)r�assertFalser�rvr:rrrrrry$s
z%SourceOnlyLoaderTests.test_is_packagecCs|j�|j�}|�|�dSrE�r�r�r:r�rrrrrr�,sz#SourceOnlyLoaderTests.test_get_codecCs"|j�|jj|j�}|�|�dSrE)r�r�r�rLr)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�r:r�r�r�rRr�r_rr]r�rrL�dirname�assertInr�r�r�rrrrf6s

z&SourceOnlyLoaderTests.test_load_modulec
Csp|jdd�t�|j��Nt��� t�dt�|j�	|j�}W5QRX|�
|�|�t|d��W5QRXdS)NFrr�r�)
rr@r�r:r�r�r�rRr�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�rwr:r])rr��returned_sourcerrr�test_get_source_encodingNsz.SourceOnlyLoaderTests.test_get_source_encodingN)r#r$r%r&rzryr�r'rfr*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)rIrr)rr�rr�rr�r�r�r�r�r�r�rr]r)rrr1r�rMrrrjsz%SourceLoaderBytecodeTests.verify_codecCs|j�|j�}|�|�dSrEr%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>Tr0)r�r�rdrrr�rLrqr�r:r)rr�rrrr�test_no_bytecodezsz*SourceLoaderBytecodeTests.test_no_bytecodecCsfdD]\}||jjkst�|jj}||j_|jjdd�|j_|j�|j�}|j|dd�||j_qdS)N)rr�Tr0)r�r�rrr�r:r)rr�Zoriginalrrrr�test_code_bad_timestamp�sz1SourceLoaderBytecodeTests.test_code_bad_timestampcCs@|jdd�|jjdd�|j_|j�|j�}|j|dd�dS)N�0000�rr5Tr0)rr�rr�r:rr&rrr�test_code_bad_magic�sz-SourceLoaderBytecodeTests.test_code_bad_magiccCs@z2dt_d|j_|j�|j�}|�|j|jj�W5dt_XdS)NFTr3)	r��dont_write_bytecoder�r�r�r:ZassertNotInrrr&rrr�test_dont_write_bytecode�sz2SourceLoaderBytecodeTests.test_dont_write_bytecodec	Csd|jdd�|jj��dj}z,|jj��d`|j�|j�}|�|�W5||jj��d_XdS)Nr7r8r)rr�r�mror
r�r:r)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��dSrEr)r�rA��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_exceptionr7r8)rrkr�r
r�r:r)rrArrrr�test_set_data_raises_exceptions�s
z9SourceLoaderBytecodeTests.test_set_data_raises_exceptions)
r#r$r%r&rr2r4r6r9r;r=rBrNrrrMrr/as
r/)r�rrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SourceLoaderGetSourceTestsz2Tests for importlib.abc.SourceLoader.get_source().cCs8d}|�d�}d}|�d�|_|�|�}|�||�dS)Nro�mod.fileux = "ü"r)�SourceOnlyLoaderMockr,r�rwr]�rr:rr�r-rrr�test_default_encoding�s

z0SourceLoaderGetSourceTests.test_default_encodingcCsPd}|�d�}d}|�d�|�d�ks*t�|�d�|_|�|�}|�||�dS)NrorDu# coding: Latin-1
x='ü'r+r)rEr,rr�rwr]rFrrr�test_decoded_source�s

z.SourceLoaderGetSourceTests.test_decoded_sourcecCsFd}|�d�}d}|�d�|_t�dd��|�}|�|�|�|�dS)NrorDzx = 42
y = -13
rT)rEr,r��io�IncrementalNewlineDecoderr!r]rw)rr:rr��expectrrr�test_universal_newlines�s
z2SourceLoaderGetSourceTests.test_universal_newlinesN)r#r$r%r&rGrHrLrrrrrC�s	
rC)rE�__main__)NF)irIr�rr��testrriZunittestrr�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_SourceLoaderInheritanceTestsrCrDrOZFrozen_MPFDefaultTestsZSource_MPFDefaultTestsr\ZFrozen_PEFDefaultTestsZSource_PEFDefaultTestsr1r`ZFrozen_LDefaultTestsZSourceLDefaultTestsrsZFrozen_RLDefaultTestsZSource_RLDefaultTestsr{rxZFrozen_ILDefaultTestsZSource_ILDefaultTestsrr}ZFrozen_ELDefaultTestsZSource_ELDefaultsTestsr�r�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_SLrrZFrozen_SourceOnlyLoaderTestsZSource_SourceOnlyLoaderTestsZskipIfr:r/ZFrozen_SLBytecodeTestsZSourceSLBytecodeTestsrCZ%Frozen_SourceOnlyLoaderGetSourceTestsZ%Source_SourceOnlyLoaderGetSourceTestsr#�mainrrrr�<module>s&



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