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_lazy.cpython-38.opt-1.pyc

U

i�fA�@s�ddlZddlmZddlmZddlZddlZddlZddlmZGdd�d�ZGdd�dej	�Z
Gd	d
�d
ejej�Z
Gdd�dej	�Zed
kr�e��dS)�N)�abc)�util�c@seZdZdd�Zdd�ZdS)�CollectInitcOs||_||_dS�N)�args�kwargs)�selfrr�r
�B/opt/alt/python38/lib64/python3.8/test/test_importlib/test_lazy.py�__init__
szCollectInit.__init__cCs|Srr
�r	�moduler
r
r�exec_moduleszCollectInit.exec_moduleN)�__name__�
__module__�__qualname__rrr
r
r
rrsrc@seZdZdd�Zdd�ZdS)�LazyLoaderFactoryTestscCsDtj�t�}|dddd�}|j}|�d|j�|�ddi|j�dS)N�module name�module path�kw)r)rr)r�
LazyLoader�factoryr�loader�assertEqualrr)r	rZlazy_loaderrr
r
r�	test_inits
z LazyLoaderFactoryTests.test_initc	Cs&|�t��tj�t�W5QRXdSr)�assertRaises�	TypeErrorrrr�object�r	r
r
r�test_validation sz&LazyLoaderFactoryTests.test_validationN)rrrrr r
r
r
rrs	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�targetr
r
r�	find_spec-s
zTestingImporter.find_speccCst|j|j�||_dSr)�exec�source_code�__dict__�loadedr
r
r
rr2szTestingImporter.exec_module)N)
rrrr"�mutated_namer+�formatr)r'rr
r
r
rr!&s

r!c@sfeZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�LazyLoaderTestsc	Cs$|�t��t�t�W5QRXdSr)rrrrrrr
r
rr9szLazyLoaderTests.test_initNcCsrt�}|dk	r||_t�tjt�|��}|j�|�}|dkrHt�	tj�}||_
|j|_|j�|�|�
|j�|Sr)r!r)rr#r"rr�
create_module�types�
ModuleType�__spec__�
__loader__r�assertIsNoner+)r	r)r�specrr
r
r�
new_module>s�zLazyLoaderTests.new_modulec
Cs|t�}t�|j��,tj|gd��t�|j�}W5QRXW5QRX|�|j�|�	|j
|�|�|j�|�	||j�dS)N)�	meta_path)r!�	test_util�uncacher"Zimport_state�	importlib�
import_moduler4r+rr3ZassertIsNotNone)r	Zimporterrr
r
r�test_e2eNs zLazyLoaderTests.test_e2ecCs|��}|�tj|j�dSr)r6rr!r,rr
r
r
r�test_attr_unchanged[sz#LazyLoaderTests.test_attr_unchangedcCs |��}d|_|�d|j�dS)N�*)r6Znew_attrrr
r
r
r�
test_new_attraszLazyLoaderTests.test_new_attrcCs |��}d|_|�d|j�dS)NZbogus)r6rrr
r
r
r�test_mutated_preexisting_attrgsz-LazyLoaderTests.test_mutated_preexisting_attrcCs |��}d|_|�d|j�dS)N�)r6�attrrr
r
r
r�test_mutated_attrnsz!LazyLoaderTests.test_mutated_attrcCs |��}|`|�t|d��dS)NrB)r6rB�assertFalse�hasattrr
r
r
r�test_delete_eventual_attrusz)LazyLoaderTests.test_delete_eventual_attrcCs |��}|`|�t|d��dS)Nr)r6rrDrEr
r
r
r�test_delete_preexisting_attr{sz,LazyLoaderTests.test_delete_preexisting_attrc
CsZt�tj��Dt�tj�}|tjtj<|��}|�	t
d��|jW5QRXW5QRXdS)NZsubstituted)r8r9r!r"r0r1�sys�modulesr6ZassertRaisesRegex�
ValueErrorr)r	Zfresh_modulerr
r
r�test_module_substitution_error�sz.LazyLoaderTests.test_module_substitution_errorc	Cs6t�tj�� |��}|tjtj<|jW5QRXdSr)r8r9r!r"r6rHrIrr
r
r
r�test_module_already_in_sys�sz*LazyLoaderTests.test_module_already_in_sys)N)rrrrr6r<r=r?r@rCrFrGrKrLr
r
r
rr.7s

r.�__main__)r:rrrHr0Zunittest�r8rZTestCaser�MetaPathFinder�Loaderr!r.r�mainr
r
r
r�<module>s
Y