Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_py_compile.cpython-39.pyc

a

��g+�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZdd�Zdd�ZGdd	�d	ee
j��ZGd
d�d�ZGdd
�d
ee
jedd�ZGdd�dee
jedd�ZGdd�de
j�Zedkr�e
��dS)�N)�support)�
script_helpercst����fdd��}|S)z+Runs function with SOURCE_DATE_EPOCH unset.csDt���(}|�d��|i|��Wd�S1s60YdS)N�SOURCE_DATE_EPOCH)r�EnvironmentVarGuardZunset��args�kwargs�env��fxn��0/usr/local/lib/python3.9/test/test_py_compile.py�wrappers

z*without_source_date_epoch.<locals>.wrapper��	functools�wraps�rrrr
r
�without_source_date_epochsrcst����fdd��}|S)z)Runs function with SOURCE_DATE_EPOCH set.csBt���&}d|d<�|i|��Wd�S1s40YdS)NZ	123456789r)rrrr
rr
rs
z'with_source_date_epoch.<locals>.wrapperrrrr
r
�with_source_date_epochsrcseZdZ�fdd�Z�ZS)�SourceDateEpochTestMetac	sZt��||||�}t|�D]:}|�d�rt||�}|r@t|�}nt|�}t|||�q|S)NZtest_)�super�__new__�dir�
startswith�getattrrr�setattr)	�mcls�name�basesZdct�source_date_epoch�cls�attr�methr��	__class__rr
r&s


zSourceDateEpochTestMeta.__new__)�__name__�
__module__�__qualname__r�
__classcell__rrr#r
r%src@s�eZdZdd�Zdd�Zdd�Zdd�Ze�e	j
�e	j�pHe	j
�
e	j�d	�d
d��Zdd
�Zdd�Zdd�Ze�ee	d�o�e	��dkd�e�e	jdkd�dd���Zdd�Zdd�Ze�ejjdkd�dd��Zd d!�Zd"d#�Zd$d%�Zd&S)'�PyCompileTestsBasecCs�tjt��d�|_tj�|jd�|_|jd|_t	j
�|j�|_tj�
t���d|_tj�
|j�d}|rvt�|�t|jd��}|�d�Wd�n1s�0YdS)N)r�_test.py�cr�w�x = 123
)�tempfile�mkdtemp�os�getcwd�	directory�path�join�source_path�pyc_path�	importlib�util�cache_from_source�
cache_path�
splitdrive�	cwd_drive�chdir�open�write)�self�drive�filerrr
�setUp7s
zPyCompileTestsBase.setUpcCs"t�|j�|jrt�|j�dS�N)�shutil�rmtreer2r<r0r=�r@rrr
�tearDownGszPyCompileTestsBase.tearDowncCs<t�|j|j�|�tj�|j��|�tj�|j	��dSrD)
�
py_compile�compiler5r6�
assertTruer0r3�exists�assertFalser:rGrrr
�test_absolute_pathLsz%PyCompileTestsBase.test_absolute_pathc	Cs�zt�|jd|j�Wn ttfy8|�d�YnN0tj�|j�sLJ�|�t	�� t
�|j|j�Wd�n1s|0YdS)Nz.actualz.need to be able to create a symlink for a file)
r0�symlinkr6�NotImplementedError�OSErrorZskipTestr3�islink�assertRaises�FileExistsErrorrIrJr5rGrrr
�test_do_not_overwrite_symlinksQsz1PyCompileTestsBase.test_do_not_overwrite_symlinksz7requires os.devnull and for it to be a non-regular filecCs>|�t�� t�|jtj�Wd�n1s00YdSrD)rSrTrIrJr5r0�devnullrGrrr
�&test_do_not_overwrite_nonregular_files]sz9PyCompileTestsBase.test_do_not_overwrite_nonregular_filescCs$t�|j�|�tj�|j��dSrD)rIrJr5rKr0r3rLr:rGrrr
�test_cache_pathesz"PyCompileTestsBase.test_cache_pathcCsxt�|j��0t�tj�|j�tj�|j	��Wd�n1sB0Y|�
tj�|j	��|�tj�|j
��dSrD)rZ
change_cwdr2rIrJr0r3�basenamer5r6rKrLrMr:rGrrr
�test_cwdis�"zPyCompileTestsBase.test_cwdcCsLt�tj�|j�tj�|j��|�tj�|j��|�	tj�|j
��dSrD)rIrJr0r3�relpathr5r6rKrLrMr:rGrrr
�test_relative_pathps
�z%PyCompileTestsBase.test_relative_path�geteuidrznon-root user required�ntz/cannot control directory permissions on Windowsc
Cs�t�|j�}t�|jtj�zN|�t�� t�|j	|j
�Wd�n1sN0YWt�|j|j�nt�|j|j�0dSrD)r0�statr2�chmod�S_IREADrS�IOErrorrIrJr5r6�st_mode)r@�moderrr
�test_exceptions_propagatevs0z,PyCompileTestsBase.test_exceptions_propagatecCsptj�tj�t�d�}t���$|�tj	|dd��Wd�n1sH0Y|�
tj�tj
�|���dS)N�bad_coding2.pyF)�doraise)r0r3r4�dirname�__file__r�captured_stderr�assertIsNonerIrJrMrLr7r8r9)r@�
bad_codingrrr
�test_bad_coding�s
2

�z"PyCompileTestsBase.test_bad_codingcCs�t�|j|j�|�tj�|j��|�tj�|j	��t
|jd��$}tj�
|��di�}Wd�n1sn0Ytj�d�r�d}nd}|�||�dS)N�rb�testr�r)rIrJr5r6rKr0r3rLrMr:r>r7�_bootstrap_external�
_classify_pyc�read�environ�get�assertEqual)r@�fp�flagsZexpected_flagsrrr
�test_source_date_epoch�s
�"z)PyCompileTestsBase.test_source_date_epochztest does not work with -Oc	Cs�tj�|jd�}tj�|�}|d}tj�|�\}}tj�|�}|�	tj�||�tj�dd�
tjj
���t|d��}|�d�Wd�n1s�0Yt�|�|�tj�|��|�tj�|��dS)Nz
foo.bar.pyr+�__pycache__zfoo.bar.{}.pycr,r-)r0r3r4r2r7r8r9�splitrYrv�format�sys�implementation�	cache_tagr>r?rIrJrKrLrM)r@Z
weird_pathr:r6�head�tailZpenultimate_tailrBrrr
�test_double_dot_no_clobber�s"��(
z-PyCompileTestsBase.test_double_dot_no_clobbercCs|�dtj|jdd��dS)Nzopt-2�)�optimize)�assertInrIrJr5rGrrr
�test_optimization_path�sz)PyCompileTestsBase.test_optimization_pathcCs�tj|jtjjd�t|jd��$}tj�	|�
�di�}Wd�n1sJ0Y|�|d�tj|jtjjd�t|jd��$}tj�	|�
�di�}Wd�n1s�0Y|�|d�dS)N)�invalidation_modernrorp�)
rIrJr5�PycInvalidationMode�CHECKED_HASHr>r:r7rqrrrsrv�UNCHECKED_HASH)r@rwrxrrr
�test_invalidation_mode�s$�
�"�
�"z)PyCompileTestsBase.test_invalidation_modec	Cs�tj�tj�t�d�}t����}|�tj	|ddd��|�tj	|ddd��|�
|��d�|�tj
�� tj	|ddd�Wd�n1s�0YWd�n1s�0YdS)NrfFr�)rg�quietT�r�)r0r3r4rhrirrjrkrIrJrv�getvaluerS�PyCompileError)r@rl�stderrrrr
�
test_quiet�s
zPyCompileTestsBase.test_quietN)r%r&r'rCrHrNrU�unittestZskipIfr0r3rLrV�isfilerWrXrZr\�hasattrr]rrermryr}rxr�r�r�r�r�rrrr
r)5s2 �
��
r)c@seZdZdS)�PyCompileTestsWithSourceEpochN�r%r&r'rrrr
r��sr�T)�	metaclassrc@seZdZdS)� PyCompileTestsWithoutSourceEpochNr�rrrr
r��sr�Fc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�PyCompileCLITestCasecCsft��|_tj�|jd�|_tj�	|j�|_
t|jd��}|�d�Wd�n1sX0YdS)Nr*r,r-)
r.r/r2r0r3r4r5r7r8r9r:r>r?)r@rBrrr
rC�s

zPyCompileCLITestCase.setUpcCst�|j�dSrD)rrFr2rGrrr
rH�szPyCompileCLITestCase.tearDowncOsT|r:|ddkr:d|vr:tjtjdddg|d��dd�Stjddg|�Ri|��S)Nr�-�input�-mrIT)r��capture_output)�
subprocess�runr}�
executable�encoderZassert_python_ok)r@rrrrr
�pycompilecmd�s
�z!PyCompileCLITestCase.pycompilecmdcGstjddg|�R�S)Nr�rI)rZassert_python_failure)r@rrrr
�pycompilecmd_failure�sz)PyCompileCLITestCase.pycompilecmd_failurecCsR|jd|jd�}|�|jd�|�|jd�|�|jd�|�tj�	|j
��dS)Nr�)r�r�)r�r5rv�
returncode�stdoutr�rKr0r3rLr:)r@�resultrrr
�
test_stdin�s
zPyCompileCLITestCase.test_stdincCsR|�|j|j�\}}}|�|d�|�|d�|�|d�|�tj�|j��dS)Nrr�)r�r5rvrKr0r3rLr:)r@�rcr�r�rrr
�test_with_files�s
z$PyCompileCLITestCase.test_with_filescCsNtj�tj�t�d�}|�|�\}}}|�|d�|�|d�|�d|�dS)Nzbadsyntax_3131.pyr�r�sSyntaxError)r0r3r4rhrir�rvr�)r@Z
bad_syntaxr�r�r�rrr
�test_bad_syntaxs
z$PyCompileCLITestCase.test_bad_syntaxcCsRtj�tj�t�d�}|�|j|�\}}}|�|d�|�|d�|�d|�dS)Nzshould_not_exists.pyr�r�sNo such file or directory)	r0r3r4rhrir�r5rvr�)r@Zshould_not_existsr�r�r�rrr
�test_file_not_existss
z)PyCompileCLITestCase.test_file_not_existsN)r%r&r'rCrHr�r�r�r�r�r�rrrr
r��s
r��__main__)r�importlib.utilr7r0rIrEr_r�r}r.r�rorZtest.supportrrr�typeZTestCaserr)r�r�r�r%�mainrrrr
�<module>s:
��6

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists