Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_py_compile.cpython-38.pyc
U

>��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.c
s4t���"}|�d��||�W5QR�SQRXdS)N�SOURCE_DATE_EPOCH)r�EnvironmentVarGuardZunset��args�kwargs�env��fxn��3/opt/cppython/lib/python3.8/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.c
s2t��� }d|d<�||�W5QR�SQRXdS)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�bases�dct�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)'�PyCompileTestsBasec	Cs�tjt��d�|_tj�|jd�|_|jd|_t	j
�|j�|_tj�
t���d|_tj�
|j�d}|rvt�|�t|jd��}|�d�W5QRXdS)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)�selfZdrive�filerrr
�setUp7s
zPyCompileTestsBase.setUpcCs"t�|j�|jrt�|j�dS�N)�shutil�rmtreer3r=r1r>�rArrr
�tearDownGszPyCompileTestsBase.tearDowncCs<t�|j|j�|�tj�|j��|�tj�|j	��dSrD)
�
py_compile�compiler6r7�
assertTruer1r4�exists�assertFalser;rGrrr
�test_absolute_pathLsz%PyCompileTestsBase.test_absolute_pathc	Csxzt�|jd|j�Wn"ttfk
r:|�d�Yn:Xtj�|j�sNt�|�	t
��t�|j
|j�W5QRXdS)Nz.actualz.need to be able to create a symlink for a file)r1�symlinkr7�NotImplementedError�OSErrorZskipTestr4�islink�AssertionError�assertRaises�FileExistsErrorrIrJr6rGrrr
�test_do_not_overwrite_symlinksQsz1PyCompileTestsBase.test_do_not_overwrite_symlinksz7requires os.devnull and for it to be a non-regular filec	Cs*|�t��t�|jtj�W5QRXdSrD)rTrUrIrJr6r1�devnullrGrrr
�&test_do_not_overwrite_nonregular_files]sz9PyCompileTestsBase.test_do_not_overwrite_nonregular_filescCs$t�|j�|�tj�|j��dSrD)rIrJr6rKr1r4rLr;rGrrr
�test_cache_pathesz"PyCompileTestsBase.test_cache_pathc	Csdt�|j��&t�tj�|j�tj�|j	��W5QRX|�
tj�|j	��|�tj�|j
��dSrD)rZ
change_cwdr3rIrJr1r4�basenamer6r7rKrLrMr;rGrrr
�test_cwdis�zPyCompileTestsBase.test_cwdcCsLt�tj�|j�tj�|j��|�tj�|j��|�	tj�|j
��dSrD)rIrJr1r4�relpathr6r7rKrLrMr;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�z*|�t��t�	|j
|j�W5QRXW5t�|j|j�XdSrD)r1�statr3�chmod�S_IREAD�st_moderT�IOErrorrIrJr6r7)rA�moderrr
�test_exceptions_propagatevsz,PyCompileTestsBase.test_exceptions_propagatec	Cs\tj�tj�t�d�}t���|�tj	|dd��W5QRX|�
tj�tj
�|���dS)N�bad_coding2.pyF)�doraise)r1r4r5�dirname�__file__r�captured_stderr�assertIsNonerIrJrMrLr8r9r:)rA�
bad_codingrrr
�test_bad_coding�s


�z"PyCompileTestsBase.test_bad_codingc	Cs�t�|j|j�|�tj�|j��|�tj�|j	��t
|jd��}tj�
|��di�}W5QRXtj�d�rvd}nd}|�||�dS)N�rb�testr�r)rIrJr6r7rKr1r4rLrMr;r?r8�_bootstrap_external�
_classify_pyc�read�environ�get�assertEqual)rA�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�W5QRXt�|�|�tj�|��|�tj�|��dS)Nz
foo.bar.pyr,�__pycache__zfoo.bar.{}.pycr-r.)r1r4r5r3r8r9r:�splitrZrw�format�sys�implementation�	cache_tagr?r@rIrJrKrLrM)rAZ
weird_pathr;r7�head�tailZpenultimate_tailrBrrr
�test_double_dot_no_clobber�s"��
z-PyCompileTestsBase.test_double_dot_no_clobbercCs|�dtj|jdd��dS)Nzopt-2�)�optimize)�assertInrIrJr6rGrrr
�test_optimization_path�sz)PyCompileTestsBase.test_optimization_pathc	Cs�tj|jtjjd�t|jd��}tj�	|�
�di�}W5QRX|�|d�tj|jtjjd�t|jd��}tj�	|�
�di�}W5QRX|�|d�dS)N)�invalidation_moderorprq�)
rIrJr6�PycInvalidationMode�CHECKED_HASHr?r;r8rrrsrtrw�UNCHECKED_HASH)rArxryrrr
�test_invalidation_mode�s,����z)PyCompileTestsBase.test_invalidation_modec
Cs�tj�tj�t�d�}t���j}|�tj	|ddd��|�tj	|ddd��|�
|��d�|�tj
��tj	|ddd�W5QRXW5QRXdS)NrgFr�)rh�quietT�r�)r1r4r5rirjrrkrlrIrJrw�getvaluerT�PyCompileError)rArm�stderrrrr
�
test_quiet�s
zPyCompileTestsBase.test_quietN)r&r'r(rCrHrNrV�unittestZskipIfr1r4rLrW�isfilerXrYr[r]�hasattrr^rrfrnrzr~ryr�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)�	metaclassr c@seZdZdS)� PyCompileTestsWithoutSourceEpochNr�rrrr
r��sr�Fc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�PyCompileCLITestCasec	CsRt��|_tj�|jd�|_tj�	|j�|_
t|jd��}|�d�W5QRXdS)Nr+r-r.)
r/r0r3r1r4r5r6r8r9r:r;r?r@)rArBrrr
rC�s

zPyCompileCLITestCase.setUpcCst�|j�dSrD)rrFr3rGrrr
rH�szPyCompileCLITestCase.tearDowncOsJ|r:|ddkr:d|kr:tjtjdddg|d��dd�Stjd|�|�S)	Nr�-�input�-mrIT)r��capture_output)r�rI)�
subprocess�runr~�
executable�encoderZassert_python_ok)rArrrrr
�pycompilecmd�s
�z!PyCompileCLITestCase.pycompilecmdcGstjd|��S)Nr�rI)r�rI)rZassert_python_failure)rArrrr
�pycompilecmd_failure�sz)PyCompileCLITestCase.pycompilecmd_failurecCsR|jd|jd�}|�|jd�|�|jd�|�|jd�|�tj�	|j
��dS)Nr�)r�r�)r�r6rw�
returncode�stdoutr�rKr1r4rLr;)rA�resultrrr
�
test_stdin�s
zPyCompileCLITestCase.test_stdincCsR|�|j|j�\}}}|�|d�|�|d�|�|d�|�tj�|j��dS)Nrr�)r�r6rwrKr1r4rLr;)rA�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)r1r4r5rirjr�rwr�)rAZ
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)	r1r4r5rirjr�r6rwr�)rAZshould_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.utilr8r1rIrEr`r�r~r/r�rprZtest.supportrrr�typeZTestCaserr*r�r�r�r&�mainrrrr
�<module>s:
��6

F1le Man4ger