Your IP : 216.73.216.213


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



��Yf��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
Gdd�dej�Ze
dkr�ej�dS)�N)�supportc@sIeZdZdd�Zdd�Zdd�Zdd�Zeje	j
je	j�pje	j
j
e	j�d	�d
d��Zdd
�Zdd�Zdd�Zdd�Zejee	d�o�e	j�dkd�eje	jdkd�dd���Zdd�Zejejjdkd�dd��Zdd �Zd!S)"�PyCompileTestsc	Cs�tj�|_tjj|jd�|_|jd|_tj	j
|j�|_tjjtj
��d|_tjj|j�d}|r�tj|�t|jd��}|jd�WdQRXdS)Nz_test.py�cr�wzx = 123
)�tempfileZmkdtemp�	directory�os�path�join�source_path�pyc_path�	importlib�util�cache_from_source�
cache_path�
splitdrive�getcwd�	cwd_drive�chdir�open�write)�selfZdrive�file�r�9/opt/alt/python35/lib64/python3.5/test/test_py_compile.py�setUps
zPyCompileTests.setUpcCs-tj|j�|jr)tj|j�dS)N)�shutilZrmtreerrrr)rrrr�tearDowns	zPyCompileTests.tearDowncCsRtj|j|j�|jtjj|j��|jtjj|j	��dS)N)
�
py_compile�compilerr�
assertTruerr	�exists�assertFalser)rrrr�test_absolute_path$sz!PyCompileTests.test_absolute_pathcCswytj|jd|j�Wn%ttfk
rE|jd�Yn.X|jt��tj	|j
|j�WdQRXdS)Nz.actualz.need to be able to create a symlink for a file)r�symlinkr�NotImplementedError�OSErrorZskipTest�assertRaises�FileExistsErrorrrr)rrrr�test_do_not_overwrite_symlinks)sz-PyCompileTests.test_do_not_overwrite_symlinksz7requires os.devnull and for it to be a non-regular filec
Cs1|jt��tj|jtj�WdQRXdS)N)r'r(rrrr�devnull)rrrr�&test_do_not_overwrite_nonregular_files5sz5PyCompileTests.test_do_not_overwrite_nonregular_filescCs0tj|j�|jtjj|j��dS)N)rrrr rr	r!r)rrrr�test_cache_path=szPyCompileTests.test_cache_pathcCs�tj|j��3tjtjj|j�tjj|j	��WdQRX|j
tjj|j	��|jtjj|j
��dS)N)rZ
change_cwdrrrrr	�basenamerrr r!r"r)rrrr�test_cwdAs
zPyCompileTests.test_cwdcCsAtjjtjjt�d�}|jtj|dd��dS)Nzbad_coding2.py�doraiseF)rr	r
�dirname�__file__�assertIsNonerr)r�
bad_codingrrr�test_bad_codingHs!zPyCompileTests.test_bad_codingcCsjtjtjj|j�tjj|j��|jtjj|j��|j	tjj|j
��dS)N)rrrr	�relpathrrr r!r"r)rrrr�test_relative_pathLsz!PyCompileTests.test_relative_path�geteuidrznon-root user required�ntz/cannot control directory permissions on WindowscCswtj|j�}tj|jtj�z1|jt��tj|j	|j
�WdQRXWdtj|j|j�XdS)N)r�statr�chmod�S_IREADr'�IOErrorrrrr�st_mode)r�moderrr�test_exceptions_propagateRs!z(PyCompileTests.test_exceptions_propagatecCsztjjtjjt�d�}tj��!|jtj	|dd��WdQRX|j
tjjtj
j|���dS)Nzbad_coding2.pyr/F)rr	r
r0r1rZcaptured_stderrr2rrr"r!r
rr)rr3rrrr4bs
!
#ztest does not work with -Oc
Cstjj|jd�}tjj|�}|d}tjj|�\}}tjj|�}|j	tjj||�tjjddj
tjj
���t|d��}|jd�WdQRXtj|�|jtjj|��|jtjj|��dS)Nz
foo.bar.pyr�__pycache__zfoo.bar.{}.pycrzx = 123
)rr	r
rr
rr�splitr-ZassertEqual�format�sys�implementation�	cache_tagrrrrr r!r")rZ
weird_pathrr�head�tailZpenultimate_tailrrrr�test_double_dot_no_clobberis
	
z)PyCompileTests.test_double_dot_no_clobbercCs&|jdtj|jdd��dS)Nzopt-2�optimize�)ZassertInrrr)rrrr�test_optimization_path}sz%PyCompileTests.test_optimization_pathN)�__name__�
__module__�__qualname__rrr#r)�unittestZskipIfrr	r!r*�isfiler+r,r.r4r6�hasattrr7�namer?rC�flagsrIrHrKrrrrr
s".$
*r�__main__)�importlib.utilr
rrrr9rCrrOZtestrZTestCaserrL�mainrrrr�<module>su