Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_pkgimport.cpython-34.pyc

�
g f�
�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZGdd�dej�Z
dd�Zedkr�e�ndS)	�N)�cache_from_source)�run_unittest�create_empty_filec@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�
TestImportcOsgd|_x1|jtjkr<|jtjtj�7_qW|jd|_tj	j
|||�dS)NZPACKAGE_z.foo)�package_name�sys�modules�random�choose�string�
ascii_letters�module_name�unittest�TestCase�__init__)�self�args�kw�r�8/opt/alt/python34/lib64/python3.4/test/test_pkgimport.pyrs
	zTestImport.__init__cCs=x6|j|jfD]"}|tjkrtj|=qqWdS)N)rr
rr)rr
rrr�remove_modulesszTestImport.remove_modulescCs�tj�|_tjj|j�tjj|j|j�|_	tj
|j	�ttjj|j	d��tjj|j	d�|_dS)Nz__init__.pyzfoo.py)
�tempfileZmkdtemp�test_dirr�path�append�os�joinrZpackage_dir�mkdirr�module_path)rrrr�setUpszTestImport.setUpcCsPtj|j�|jtjj|j�d�tjj|j�|j�dS)Nr)	�shutilZrmtreerZassertNotEqualrr�count�remover)rrrr�tearDown#szTestImport.tearDownc	Cs]t|j�}tjj|�r1tj|�nt|jd��}|j|�WdQXdS)N�w)rrrr�existsr"�open�write)r�contentsZ
compiled_path�frrr�rewrite_file)s
zTestImport.rewrite_filecCs)|jd�yt|j�Wntk
r2Yn
Xtd��|j|jtj�|jt	tj|j
d��d}x,|tt�kr�|t
jtj�7}q~W|j|�yt|j�Wntk
r�Yn
Xtd��|jd|�t|j�j}|jt||�d�dS)N�forzFailed to induce SyntaxError�foo�azFailed to induce NameError.z%s = 1�)r*�
__import__r
�SyntaxError�RuntimeErrorZassertNotInrrZassertFalse�hasattrr�dir�__builtins__r	r
rr�	NameErrorr,ZassertEqual�getattr)r�var�modulerrr�test_package_import__semantics0s(

 

z)TestImport.test_package_import__semanticsN)	�__name__�
__module__�__qualname__rrrr#r*r9rrrrrs	rcCstt�dS)N)rrrrrr�	test_mainOsr=�__main__)rrr rr	rr�importlib.utilrZtest.supportrrrrr=r:rrrr�<module>sC