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.opt-1.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.csR�fdd��jD��_t�d�r>�jj��fdd��jD��_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�
subclassesr	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__rrrrr 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#rrrrrr.Msr.c@seZdZdgZdddgZdS)�
InspectLoaderr/r'r(�ExtensionFileLoaderNr+rrrrr0Vsr0c@seZdZdgZdgZdS)�ExecutionLoaderr0r1Nr+rrrrr2`sr2c@seZdZddgZddgZdS)�
FileLoaderr.r2�SourceFileLoader�SourcelessFileLoaderNr+rrrrr3jsr3c@seZdZddgZdgZdS)�SourceLoaderr.r2r4Nr+rrrrr6tsr6FcsB�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)�instrrr9�s�)r!r
�items�	test_utilZsplit_frozen)Z
base_classr8r<�kwargs�baser)r<r8r�make_abc_subclasses�s
�
�rAc@seZdZedd��ZdS)�ABCTestHarnesscCs|j|j}|�}||j_|S�N)�SPLITr:�	__class__�ins)rr;rFrrrrF�szABCTestHarness.insN)r!r"r#�propertyrFrrrrrB�srBcseZdZ�fdd�Z�ZS)r%cst��||�SrC)�super�find_module)r�fullname�path�rErrrI�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��dSrC�rF�invalidate_cachesrrrr�test_invalidate_caches�sz2MetaPathFinderDefaultsTests.test_invalidate_cachesN)r!r"r#rAr%rDrUrXrrrrrN�srNcseZdZ�fdd�Z�ZS)r,cst��|�SrC)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��dSrCrVrrrrrX�sz3PathEntryFinderDefaultsTests.test_invalidate_cachesN)	r!r"r#rAr,rDr]rIrXrrrrr[�sr[cseZdZ�fdd�Z�ZS)r/cst��|�SrC)rH�load_modulerZrLrrr^�szLoader.load_module)r!r"r#r^rMrrrLrr/�sr/c@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#rAr/rDrbrerorrrrr_�sr_cseZdZ�fdd�Z�ZS)r.cst��|�SrC)rH�get_data�rrKrLrrrp�szResourceLoader.get_data)r!r"r#rprMrrrLrr.�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#rAr.rDrtrrrrrr�srrcs(eZdZ�fdd�Z�fdd�Z�ZS)r0cst��|�SrC)rH�
is_packagerZrLrrruszInspectLoader.is_packagecst��|�SrC)rH�
get_sourcerZrLrrrvszInspectLoader.get_source)r!r"r#rurvrMrrrLrr0�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_ILrDrxryrrrrrwsrwcseZdZ�fdd�Z�ZS)r2cst��|�SrC)rH�get_filenamerZrLrrr{szExecutionLoader.get_filename)r!r"r#r{rMrrrLrr2sc@seZdZeZdd�ZdS)�ExecutionLoaderDefaultsTestsc	Cs&|�t��|j�d�W5QRXdSrf)rcrdrFr{rrrr�test_get_filename*sz.ExecutionLoaderDefaultsTests.test_get_filenameN)r!r"r#�SPLIT_ELrDr}rrrrr|&sr|cs@eZdZ�fdd�Z�fdd�Z�fdd�Z�fdd�Z�ZS)	�ResourceReadercst�j||�SrC)rH�
open_resource�r�argsr?rLrrr�6szResourceReader.open_resourcecst�j||�SrC)rH�
resource_pathr�rLrrr�9szResourceReader.resource_pathcst�j||�SrC)rH�is_resourcer�rLrrr�<szResourceReader.is_resourcecst�j||�SrC)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����dSrC)r\�listrFr�rrrr�
test_contentsSsz)ResourceReaderDefaultsTests.test_contentsN)
r!r"r#rArrDr�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|_�SrC��
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�rKr8rTrrr�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
||_�SrCr�)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�r8rTrrrr��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
||_dSrC)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
r/)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!r8ZassertIsNotNone�__path__r�)rr�r8r�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�)rr8r�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�dSrC)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��|��}|�|�W5QRXW5QRXdSrC)r�rd�side_effectrcr�r��r�mocked_get_coder�rrr�test_get_code_ImportErrorEs

z6InspectLoaderLoadModuleTests.test_get_code_ImportErrorc
CsF|���4}d|_|�t��|��}|�|�W5QRXW5QRXdSrC)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
||_dSrC�rKrqrrr�__init__�szSourceOnlyLoader.__init__cCs||jkrt�|jSrC)rKrsr�rqrrrrp�s
zSourceOnlyLoader.get_datacCs|jSrCr�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)r6rNcs�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�dSrC)rKrHrpr�r�OSErrorrqrLrrrp�s


zSourceLoader.get_datacCs||jkrt�|j|jd�S)N)�mtime�size)rKrsr�r�rqrrr�
path_stats�s
zSourceLoader.path_statscCst|�|j|<||jkSrC)rrr�)rrKr�rrr�set_data�szSourceLoader.set_data)N)	r!r"r#r�r�rprr	rMrrrLrr6�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�joinr8rr��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!r8�__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
�|�|�dSrC)rhrir8rKrrrrrr�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�dSrC)rr�rrr�
raise_OSErrorsz<SourceOnlyLoaderTests.test_get_source.<locals>.raise_OSError)
r�r��decoder\rvr8rprcrd�	exception)rZexpected_sourcer�cmrrrrysz%SourceOnlyLoaderTests.test_get_sourcecCs\|jdd�|�|j�|j��|jdd�|�|j�|j��|�|j�|jd��dS)NFrTz	.__init__)r�assertFalser�rur8rrrrrrx$s
z%SourceOnlyLoaderTests.test_is_packagecCs|j�|j�}|�|�dSrC�r�r�r8r�rrrrrr�,sz#SourceOnlyLoaderTests.test_get_codecCs"|j�|jj|j�}|�|�dSrC)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�r8r�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�r8r�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�rvr8r\)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)rrr0r�rLrrrjsz%SourceLoaderBytecodeTests.verify_codecCs|j�|j�}|�|�dSrCr$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�r8r)rr�rrrr�test_no_bytecodezsz*SourceLoaderBytecodeTests.test_no_bytecodecCsVdD]L}|jj}||j_|jjdd�|j_|j�|j�}|j|dd�||j_qdS)N)rr�Tr/)r�r�rr�r8r)rr�Zoriginalrrrr�test_code_bad_timestamp�sz1SourceLoaderBytecodeTests.test_code_bad_timestampcCs@|jdd�|jjdd�|j_|j�|j�}|j|dd�dS)N�0000�rr4Tr/)rr�rr�r8rr%rrr�test_code_bad_magic�sz-SourceLoaderBytecodeTests.test_code_bad_magiccCs@z2dt_d|j_|j�|j�}|�|j|jj�W5dt_XdS)NFTr2)	r��dont_write_bytecoder�r�r�r8ZassertNotInrrr%rrr�test_dont_write_bytecode�sz2SourceLoaderBytecodeTests.test_dont_write_bytecodec	Csd|jdd�|jj��dj}z,|jj��d`|j�|j�}|�|�W5||jj��d_XdS)Nr6r7r)rr�rE�mror	r�r8r)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��dSrCr)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_exceptionr6r7)rrjr�r	r�r8r)rr@rrrr�test_set_data_raises_exceptions�s
z9SourceLoaderBytecodeTests.test_set_data_raises_exceptions)
r!r"r#r$rr1r3r5r8r:r<rArMrrrLrr.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\�rr8rr�r,rrr�test_default_encoding�s

z0SourceLoaderGetSourceTests.test_default_encodingcCs8d}|�d�}d}|�d�|_|�|�}|�||�dS)NrnrCu# coding: Latin-1
x='ü'r*rDrFrrr�test_decoded_source�s

z.SourceLoaderGetSourceTests.test_decoded_sourcecCsFd}|�d�}d}|�d�|_t�dd��|�}|�|�|�|�dS)NrnrCzx = 42
y = -13
rT)rEr+r��io�IncrementalNewlineDecoderr r\rv)rr8rr��expectrrr�test_universal_newlines�s
z2SourceLoaderGetSourceTests.test_universal_newlinesN)r!r"r#r$rGrHrLrrrrrB�s	
rB)rE�__main__)NF)irIr�rr��testrrhZunittestrr�r�rr>Zimport_importlibr�r
rrr%Z	test_bothZ%Frozen_MetaPathFinderInheritanceTestsZ%Source_MetaPathFinderInheritanceTestsr,Z&Frozen_PathEntryFinderInheritanceTestsZ&Source_PathEntryFinderInheritanceTestsr.Z%Frozen_ResourceLoaderInheritanceTestsZ%Source_ResourceLoaderInheritanceTestsr0Z$Frozen_InspectLoaderInheritanceTestsZ$Source_InspectLoaderInheritanceTestsr2Z&Frozen_ExecutionLoaderInheritanceTestsZ&Source_ExecutionLoaderInheritanceTestsr3Z!Frozen_FileLoaderInheritanceTestsZ!Source_FileLoaderInheritanceTestsr6Z#Frozen_SourceLoaderInheritanceTestsZ#Source_SourceLoaderInheritanceTestsrArBrNZFrozen_MPFDefaultTestsZSource_MPFDefaultTestsr[ZFrozen_PEFDefaultTestsZSource_PEFDefaultTestsr/r_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_SourceOnlyLoaderTestsZskipIfr9r.ZFrozen_SLBytecodeTestsZSourceSLBytecodeTestsrBZ%Frozen_SourceOnlyLoaderGetSourceTestsZ%Source_SourceOnlyLoaderGetSourceTestsr!�mainrrrr�<module>s&



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