HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_py_compile.cpython-310.pyc
o

�i�-�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZdd�Zdd�ZGdd	�d	ee
j��ZGd
d�d�ZGdd
�d
ee
jedd�ZGdd�dee
jedd�ZGdd�de
j�Zedkr}e
��dSdS)�N)�support)�	os_helper�
script_helperc�t����fdd��}|S)z+Runs function with SOURCE_DATE_EPOCH unset.csDt���}|�d��|i|��Wd�S1swYdS)N�SOURCE_DATE_EPOCH)r�EnvironmentVarGuardZunset��args�kwargs�env��fxn��1/usr/local/lib/python3.10/test/test_py_compile.py�wrappers

$�z*without_source_date_epoch.<locals>.wrapper��	functools�wraps�r
rrrr�without_source_date_epoch�rcr)z)Runs function with SOURCE_DATE_EPOCH set.csBt���}d|d<�|i|��Wd�S1swYdS)NZ	123456789r)rrrrrrrs
$�z'with_source_date_epoch.<locals>.wrapperrrrrr�with_source_date_epochrrcseZdZ�fdd�Z�ZS)�SourceDateEpochTestMetac	sZt��||||�}t|�D]}|�d�r*t||�}|r t|�}nt|�}t|||�q
|S)NZtest_)�super�__new__�dir�
startswith�getattrrr�setattr)	�mcls�name�basesZdct�source_date_epoch�cls�attr�methr��	__class__rrr&s


�zSourceDateEpochTestMeta.__new__)�__name__�
__module__�__qualname__r�
__classcell__rrr&rr%src@s�eZdZdd�Zdd�Zdd�Zdd�Ze�e	j
�e	j�p$e	j
�
e	j�d	�d
d��Zdd
�Zdd�Zdd�Ze�ee	d�oCe	��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}|r;t�|�t|jd��}|�d�Wd�dS1sRwYdS)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�filerrr�setUp7s
"�zPyCompileTestsBase.setUpcCs&t�|j�|jrt�|j�dSdS�N)�shutil�rmtreer5r?r3r@�rCrrr�tearDownGs�zPyCompileTestsBase.tearDowncCs<t�|j|j�|�tj�|j��|�tj�|j	��dSrG)
�
py_compile�compiler8r9�
assertTruer3r6�exists�assertFalser=rJrrr�test_absolute_pathLsz%PyCompileTestsBase.test_absolute_pathc	Cs�zt�|jd|j�Wnttfy|�d�YdSwtj�|j�s'J�|�t	��t
�|j|j�Wd�dS1s@wYdS)Nz.actualz.need to be able to create a symlink for a file)
r3�symlinkr9�NotImplementedError�OSErrorZskipTestr6�islink�assertRaises�FileExistsErrorrLrMr8rJrrr�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�dS1swYdSrG)rVrWrLrMr8r3�devnullrJrrr�&test_do_not_overwrite_nonregular_files]s"�z9PyCompileTestsBase.test_do_not_overwrite_nonregular_filescCs$t�|j�|�tj�|j��dSrG)rLrMr8rNr3r6rOr=rJrrr�test_cache_pathesz"PyCompileTestsBase.test_cache_pathcCsxt�|j��t�tj�|j�tj�|j	��Wd�n1s!wY|�
tj�|j	��|�tj�|j
��dSrG)rZ
change_cwdr5rLrMr3r6�basenamer8r9rNrOrPr=rJrrr�test_cwdis��zPyCompileTestsBase.test_cwdcCsLt�tj�|j�tj�|j��|�tj�|j��|�	tj�|j
��dSrG)rLrMr3r6�relpathr8r9rNrOrPr=rJrrr�test_relative_pathps
�z%PyCompileTestsBase.test_relative_path�geteuidrznon-root user required�ntz/cannot control directory permissions on Windowsc
Cs�t�|j�}t�|jtj�z3|�t��t�|j	|j
�Wd�n1s'wYWt�|j|j�dSWt�|j|j�dSt�|j|j�wrG)r3�statr5�chmod�S_IREADrV�IOErrorrLrMr8r9�st_mode)rC�moderrr�test_exceptions_propagatevs��&z,PyCompileTestsBase.test_exceptions_propagatecCsptj�tj�t�d�}t���|�tj	|dd��Wd�n1s$wY|�
tj�tj
�|���dS)N�bad_coding2.pyF)�doraise)r3r6r7�dirname�__file__r�captured_stderr�assertIsNonerLrMrPrOr:r;r<)rC�
bad_codingrrr�test_bad_coding�s
�


�z"PyCompileTestsBase.test_bad_codingcCs�t�|j|j�|�tj�|j��|�tj�|j	��t
|jd��}tj�
|��di�}Wd�n1s7wYtj�d�rEd}nd}|�||�dS)N�rb�testr�r)rLrMr8r9rNr3r6rOrPr=rAr:�_bootstrap_external�
_classify_pyc�read�environ�get�assertEqual)rC�fp�flagsZexpected_flagsrrr�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�n1sJwYt�|�|�tj�|��|�tj�|��dS)Nz
foo.bar.pyr.�__pycache__zfoo.bar.{}.pycr/r0)r3r6r7r5r:r;r<�splitr\ry�format�sys�implementation�	cache_tagrArBrLrMrNrOrP)rCZ
weird_pathr=r9�head�tailZpenultimate_tailrErrr�test_double_dot_no_clobber�s$���
z-PyCompileTestsBase.test_double_dot_no_clobbercCs|�dtj|jdd��dS)Nzopt-2�)�optimize)�assertInrLrMr8rJrrr�test_optimization_path�sz)PyCompileTestsBase.test_optimization_pathcCs�tj|jtjjd�t|jd��}tj�	|�
�di�}Wd�n1s%wY|�|d�tj|jtjjd�t|jd��}tj�	|�
�di�}Wd�n1sUwY|�|d�dS)N)�invalidation_moderqrrrs�)
rLrMr8�PycInvalidationMode�CHECKED_HASHrAr=r:rtrurvry�UNCHECKED_HASH)rCrzr{rrr�test_invalidation_mode�s(�
���
��z)PyCompileTestsBase.test_invalidation_modec	Cs�tj�tj�t�d�}t���M}|�tj	|ddd��|�tj	|ddd��|�
|��d�|�tj
��tj	|ddd�Wd�n1sGwYWd�dSWd�dS1s_wYdS)NriFr�)rj�quietT�r�)r3r6r7rkrlrrmrnrLrMry�getvaluerV�PyCompileError)rCro�stderrrrr�
test_quiet�s
��"�zPyCompileTestsBase.test_quietN)r(r)r*rFrKrQrX�unittestZskipIfr3r6rOrY�isfilerZr[r]r_�hasattrr`r rhrpr|r�r{r�r�r�r�r�rrrrr,5s4 �
��
r,c@�eZdZdS)�PyCompileTestsWithSourceEpochN�r(r)r*rrrrr���r�T)�	metaclassr"c@r�)� PyCompileTestsWithoutSourceEpochNr�rrrrr��r�r�Fc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�PyCompileCLITestCasecCsht��|_tj�|jd�|_tj�	|j�|_
t|jd��}|�d�Wd�dS1s-wYdS)Nr-r/r0)
r1r2r5r3r6r7r8r:r;r<r=rArB)rCrErrrrF�s
"�zPyCompileCLITestCase.setUpcCst�|j�dSrG)rrIr5rJrrrrK�szPyCompileCLITestCase.tearDowncOsT|r|ddkrd|vrtjtjdddg|d��dd�Stjddg|�Ri|��S)Nr�-�input�-mrLT)r��capture_output)�
subprocess�runr��
executable�encoderZassert_python_ok)rCr	r
rrr�pycompilecmd�s
�z!PyCompileCLITestCase.pycompilecmdcGstjddg|�R�S)Nr�rL)rZassert_python_failure)rCr	rrr�pycompilecmd_failure�sz)PyCompileCLITestCase.pycompilecmd_failurecCsR|jd|jd�}|�|jd�|�|jd�|�|jd�|�tj�	|j
��dS)Nr�)r�r�)r�r8ry�
returncode�stdoutr�rNr3r6rOr=)rC�resultrrr�
test_stdin�s
zPyCompileCLITestCase.test_stdincCsR|�|j|j�\}}}|�|d�|�|d�|�|d�|�tj�|j��dS)Nrr�)r�r8ryrNr3r6rOr=)rC�rcr�r�rrr�test_with_files�s
z$PyCompileCLITestCase.test_with_filescCsNtj�tj�t�d�}|�|�\}}}|�|d�|�|d�|�d|�dS)N�badsyntax_3131.pyr�r�sSyntaxError)r3r6r7rkrlr�ryr��rCZ
bad_syntaxr�r�r�rrr�test_bad_syntaxs
z$PyCompileCLITestCase.test_bad_syntaxcCsPtj�tj�t�d�}|�d|�\}}}|�|d�|�|d�|�|d�dS)Nr��-qr�r�)r3r6r7rkrlr�ryr�rrr�test_bad_syntax_with_quiets
z/PyCompileCLITestCase.test_bad_syntax_with_quietcCsVtj�tj�t�d�}|�|j|�\}}}|�|d�|�|d�|�d|�	��dS)N�should_not_exists.pyr�r�sno such file or directory)
r3r6r7rkrlr�r8ryr��lower�rCZshould_not_existsr�r�r�rrr�test_file_not_existss
z)PyCompileCLITestCase.test_file_not_existscCsTtj�tj�t�d�}|�d|j|�\}}}|�|d�|�|d�|�|d�dS)Nr�r�r�r�)r3r6r7rkrlr�r8ryr�rrr�test_file_not_exists_with_quiets
z4PyCompileCLITestCase.test_file_not_exists_with_quietN)
r(r)r*rFrKr�r�r�r�r�r�r�r�rrrrr��s
r��__main__)r�importlib.utilr:r3rLrHrbr�r�r1r�rrrZtest.supportrrrr�typeZTestCaserr,r�r�r�r(�mainrrrr�<module>s>
��D�