Your IP : 216.73.216.52


Current Path : /opt/alt/python310/lib64/python3.10/test/test_importlib/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/test_importlib/__pycache__/test_lazy.cpython-310.pyc

o

0�iA�@s�ddlZddlmZddlmZddlZddlZddlZddlmZGdd�d�ZGdd�dej	�Z
Gd	d
�d
ejej�Z
Gdd�dej	�Zed
krPe��dSdS)�N)�abc)�util�c@�eZdZdd�Zdd�ZdS)�CollectInitcOs||_||_dS�N)�args�kwargs)�selfrr	�r�D/opt/alt/python310/lib64/python3.10/test/test_importlib/test_lazy.py�__init__
s
zCollectInit.__init__cCs|Srr�r
�modulerrr�exec_moduleszCollectInit.exec_moduleN)�__name__�
__module__�__qualname__r
rrrrrrsrc@r)�LazyLoaderFactoryTestscCsDtj�t�}|dddd�}|j}|�d|j�|�ddi|j�dS)N�module name�module path�kw)r)rr)r�
LazyLoader�factoryr�loader�assertEqualrr	)r
rZlazy_loaderrrrr�	test_inits
z LazyLoaderFactoryTests.test_initcCs<|�t��tj�t�Wd�dS1swYdSr)�assertRaises�	TypeErrorrrr�object�r
rrr�test_validation s"�z&LazyLoaderFactoryTests.test_validationN)rrrrr!rrrrrs	rc@s4eZdZdZdZdZd�e�Zd	dd�Zdd�Z	dS)
�TestingImporterZlazy_loader_testZchangedNzattr = 42; __name__ = {!r}cCs ||jkrdSt�|t�|��Sr)�module_namer�spec_from_loaderr)r
�name�path�targetrrr�	find_spec-s
zTestingImporter.find_speccCst|j|j�||_dSr)�exec�source_code�__dict__�loadedrrrrr2s
zTestingImporter.exec_moduler)
rrrr#�mutated_namer,�formatr*r(rrrrrr"&s

r"c@sfeZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�LazyLoaderTestscCs:|�t��t�t�Wd�dS1swYdSr)rrrrrr rrrr9s"�zLazyLoaderTests.test_initNcCsrt�}|dur
||_t�tjt�|��}|j�|�}|dur$t�	tj�}||_
|j|_|j�|�|�
|j�|Sr)r"r*rr$r#rr�
create_module�types�
ModuleType�__spec__�
__loader__r�assertIsNoner,)r
r*r�specrrrr�
new_module>s�zLazyLoaderTests.new_modulec	Cs�t�}|jdus
J�t�|j��%tj|gd��t�|j�}Wd�n1s)wYWd�n1s8wY|�|j�|�	|j
|�|�|j�|�	||j�dS)N)�	meta_path)r"r,�	test_util�uncacher#Zimport_state�	importlib�
import_moduler5rr4ZassertIsNotNone)r
Zimporterrrrr�test_e2eNs���zLazyLoaderTests.test_e2ecCs|��}|�tj|j�dSr)r7rr"r-rrrrr�test_attr_unchanged[sz#LazyLoaderTests.test_attr_unchangedcC� |��}d|_|�d|j�dS)N�*)r7Znew_attrrrrrr�
test_new_attraszLazyLoaderTests.test_new_attrcCr?)NZbogus)r7rrrrrr�test_mutated_preexisting_attrg�z-LazyLoaderTests.test_mutated_preexisting_attrcCr?)N�)r7�attrrrrrr�test_mutated_attrnrCz!LazyLoaderTests.test_mutated_attrcC� |��}|`|�t|d��dS)NrE)r7rE�assertFalse�hasattrrrrr�test_delete_eventual_attrusz)LazyLoaderTests.test_delete_eventual_attrcCrG)Nr)r7rrHrIrrrr�test_delete_preexisting_attr{sz,LazyLoaderTests.test_delete_preexisting_attrc	Cs�t�tj��:t�tj�}|tjtj<|��}|�	t
d��|jWd�n1s+wYWd�dSWd�dS1sCwYdS)NZsubstituted)r9r:r"r#r1r2�sys�modulesr7ZassertRaisesRegex�
ValueErrorr)r
Zfresh_modulerrrr�test_module_substitution_error�s��"�z.LazyLoaderTests.test_module_substitution_errorcCsLt�tj��|��}|tjtj<|jWd�dS1swYdSr)r9r:r"r#r7rLrMrrrrr�test_module_already_in_sys�s
"�z*LazyLoaderTests.test_module_already_in_sysr)rrrrr7r=r>rArBrFrJrKrOrPrrrrr/7s

r/�__main__)r;rrrLr1Zunittest�r9rZTestCaserZMetaPathFinder�Loaderr"r/r�mainrrrr�<module>s
Y�