Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib64/python3.6/test/test_importlib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/test/test_importlib/__pycache__/test_lazy.cpython-36.opt-2.pyc

3

��2aB�@s�ddlZddlmZddlmZddlZddlZddlZddlmZGdd�d�ZGdd�dej	�Z
Gd	d
�d
ejej�Z
Gdd�dej	�Zed
kr�ej�dS)�N)�abc)�util�c@seZdZdd�Zdd�ZdS)�CollectInitcOs||_||_dS)N)�args�kwargs)�selfrr�r	�./opt/alt/python36/lib64/python3.6/test_lazy.py�__init__
szCollectInit.__init__cCs|S)Nr	)r�moduler	r	r
�exec_moduleszCollectInit.exec_moduleN)�__name__�
__module__�__qualname__rr
r	r	r	r
rsrc@seZdZdd�Zdd�ZdS)�LazyLoaderFactoryTestscCsDtjjt�}|dddd�}|j}|jd|j�|jddi|j�dS)N�module name�module path�kw)r)rr)r�
LazyLoader�factoryr�loader�assertEqualrr)rrZlazy_loaderrr	r	r
�	test_inits
z LazyLoaderFactoryTests.test_initc	Cs&|jt��tjjt�WdQRXdS)N)�assertRaises�	TypeErrorrrr�object)rr	r	r
�test_validation sz&LazyLoaderFactoryTests.test_validationN)rrrrrr	r	r	r
rs	rc@s4eZdZdZdZdZdje�Zd	dd�Zdd�Z	dS)
�TestingImporterZlazy_loader_testZchangedNzattr = 42; __name__ = {!r}cCs ||jkrdStj|tj|��S)N)�module_namer�spec_from_loaderr)r�name�path�targetr	r	r
�	find_spec-s
zTestingImporter.find_speccCst|j|j�||_dS)N)�exec�source_code�__dict__�loaded)rrr	r	r
r
2szTestingImporter.exec_module)N)
rrrr�mutated_namer(�formatr&r$r
r	r	r	r
r&s

rc@sfeZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�LazyLoaderTestsc	Cs$|jt��tjt�WdQRXdS)N)rrrrr)rr	r	r
r9szLazyLoaderTests.test_initNcCsrt�}|dk	r||_tjtjtj|��}|jj|�}|dkrHtj	tj�}||_
|j|_|jj|�|j
|j�|S)N)rr&rr rrr�
create_module�types�
ModuleType�__spec__�
__loader__r
�assertIsNoner()rr&r�specrr	r	r
�
new_module>szLazyLoaderTests.new_modulecCs|t�}tj|j��,tj|gd��tj|j�}WdQRXWdQRX|j|j�|j	|j
|�|j|j�|j	||j�dS)N)�	meta_path)r�	test_util�uncacherZimport_state�	importlib�
import_moduler1r(rr0ZassertIsNotNone)rZimporterrr	r	r
�test_e2eNs zLazyLoaderTests.test_e2ecCs|j�}|jtj|j�dS)N)r3rrr)r)rrr	r	r
�test_attr_unchanged[sz#LazyLoaderTests.test_attr_unchangedcCs |j�}d|_|jd|j�dS)N�*)r3Znew_attrr)rrr	r	r
�
test_new_attraszLazyLoaderTests.test_new_attrcCs |j�}d|_|jd|j�dS)NZbogus)r3rr)rrr	r	r
�test_mutated_preexisting_attrgsz-LazyLoaderTests.test_mutated_preexisting_attrcCs |j�}d|_|jd|j�dS)N�)r3�attrr)rrr	r	r
�test_mutated_attrnsz!LazyLoaderTests.test_mutated_attrcCs |j�}|`|jt|d��dS)Nr?)r3r?�assertFalse�hasattr)rrr	r	r
�test_delete_eventual_attrusz)LazyLoaderTests.test_delete_eventual_attrcCs |j�}|`|jt|d��dS)Nr)r3rrArB)rrr	r	r
�test_delete_preexisting_attr{sz,LazyLoaderTests.test_delete_preexisting_attrcCsZtjtj��Dtjtj�}|tjtj<|j�}|j	t
d��|jWdQRXWdQRXdS)NZsubstituted)r5r6rrr-r.�sys�modulesr3ZassertRaisesRegex�
ValueErrorr)rZfresh_modulerr	r	r
�test_module_substitution_error�sz.LazyLoaderTests.test_module_substitution_errorc
Cs6tjtj�� |j�}|tjtj<|jWdQRXdS)N)r5r6rrr3rErFr)rrr	r	r
�test_module_already_in_sys�sz*LazyLoaderTests.test_module_already_in_sys)N)rrrrr3r9r:r<r=r@rCrDrHrIr	r	r	r
r+7s

r+�__main__)r7rrrEr-Zunittest�r5rZTestCaser�MetaPathFinder�Loaderrr+r�mainr	r	r	r
�<module>s
Y