Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/test_importlib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/test_importlib/__pycache__/test_lazy.cpython-35.opt-1.pyc



��Yf��@s�ddlZddlmZddlmZddlZddlZddlZddlmZGdd�d�ZGdd�dej	�Z
Gd	d
�d
ejej�Z
Gdd�dej	�Zed
kr�ej�dS)�N)�abc)�util�c@s(eZdZdd�Zdd�ZdS)�CollectInitcOs||_||_dS)N)�args�kwargs)�selfrr�r	�B/opt/alt/python35/lib64/python3.5/test/test_importlib/test_lazy.py�__init__
s	zCollectInit.__init__cCs|S)Nr	)r�moduler	r	r
�exec_moduleszCollectInit.exec_moduleN)�__name__�
__module__�__qualname__rr
r	r	r	r
rsrc@s(eZdZdd�Zdd�ZdS)�LazyLoaderFactoryTestscCs`tjjt�}|dddd�}|j}|jd|j�|jddi|j�dS)N�module name�module path�kw)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 sz&LazyLoaderFactoryTests.test_validationN)rrrrrr	r	r	r
rs	rc@sLeZdZdZdZdZdje�Zddd�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-szTestingImporter.find_speccCs t|j|j�||_dS)N)�exec�source_code�__dict__�loaded)rrr	r	r
r
2szTestingImporter.exec_module)
rrrr�mutated_namer(�formatr&r$r
r	r	r	r
r&src@s�eZdZdd�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
r9szLazyLoaderTests.test_initNcCs�t�}|dk	r||_tjtjtj|��}|jj|�}||_|j|_	|jj
|�|j|j�|S)N)
rr&rr rrr�
create_module�__spec__�
__loader__r
�assertIsNoner()rr&r�specrr	r	r
�
new_module>s			zLazyLoaderTests.new_modulecCs�t�}tj|j��4tjd|g��tj|j�}WdQRXWdQRX|j|j�|j	|j
|�|j|j�|j	||j�dS)N�	meta_path)r�	test_util�uncacherZimport_state�	importlib�
import_moduler/r(rr.ZassertIsNotNone)rZimporterrr	r	r
�test_e2eLs	 zLazyLoaderTests.test_e2ecCs&|j�}|jtj|j�dS)N)r1rrr)r)rrr	r	r
�test_attr_unchangedYsz#LazyLoaderTests.test_attr_unchangedcCs,|j�}d|_|jd|j�dS)N�*)r1Znew_attrr)rrr	r	r
�
test_new_attr_s	zLazyLoaderTests.test_new_attrcCs,|j�}d|_|jd|j�dS)NZbogus)r1rr)rrr	r	r
�test_mutated_preexisting_attres	z-LazyLoaderTests.test_mutated_preexisting_attrcCs,|j�}d|_|jd|j�dS)N�)r1�attrr)rrr	r	r
�test_mutated_attrls	z!LazyLoaderTests.test_mutated_attrcCs,|j�}|`|jt|d��dS)Nr=)r1r=�assertFalse�hasattr)rrr	r	r
�test_delete_eventual_attrssz)LazyLoaderTests.test_delete_eventual_attrcCs,|j�}|`|jt|d��dS)Nr)r1rr?r@)rrr	r	r
�test_delete_preexisting_attrysz,LazyLoaderTests.test_delete_preexisting_attrcCsmtjtj��Ttjtj�}|tjtj<|j�}|j	t
d��|jWdQRXWdQRXdS)NZsubstituted)r3r4rr�types�
ModuleType�sys�modulesr1ZassertRaisesRegex�
ValueErrorr)rZfresh_modulerr	r	r
�test_module_substitution_error~sz.LazyLoaderTests.test_module_substitution_errorc
CsAtjtj��(|j�}|tjtj<|jWdQRXdS)N)r3r4rrr1rErFr)rrr	r	r
�test_module_already_in_sys�sz*LazyLoaderTests.test_module_already_in_sys)rrrrr1r7r8r:r;r>rArBrHrIr	r	r	r
r+7s
r+�__main__)r5rrrErCZunittest�r3rZTestCaser�MetaPathFinder�Loaderrr+r�mainr	r	r	r
�<module>s
W