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.7/test/__pycache__/test_py_compile.cpython-37.opt-2.pyc
B

��g��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZdd�Zdd�Z
Gdd�dee	j��ZGd	d
�d
�ZGdd�dee	jed
d�ZGdd�dee	jedd�Zedkr�e	��dS)�N)�supportcst����fdd��}|S)Nc	s(t���}|�d��||�SQRXdS)N�SOURCE_DATE_EPOCH)r�EnvironmentVarGuardZunset)�args�kwargs�env)�fxn��0/usr/local/lib/python3.7/test/test_py_compile.py�wrappers

z*without_source_date_epoch.<locals>.wrapper)�	functools�wraps)rrr	)rr
�without_source_date_epochsrcst����fdd��}|S)Nc	s&t���}d|d<�||�SQRXdS)NZ	123456789r)rr)rrr)rr	r
rs
z'with_source_date_epoch.<locals>.wrapper)rr
)rrr	)rr
�with_source_date_epochsrcseZdZ�fdd�Z�ZS)�SourceDateEpochTestMetac	s^t��||||�}xFt|�D]:}|�d�rt||�}|rBt|�}nt|�}t|||�qW|S)NZtest_)�super�__new__�dir�
startswith�getattrrr�setattr)	�mcls�name�basesZdct�source_date_epoch�cls�attrZmethr)�	__class__r	r
r$s


zSourceDateEpochTestMeta.__new__)�__name__�
__module__�__qualname__r�
__classcell__r	r	)rr
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$S)%�PyCompileTestsBasec	Cs�tjt��d�|_tj�|jd�|_|jd|_t	j
�|j�|_tj�
t���d|_tj�
|j�d}|rvt�|�t|jd��}|�d�WdQRXdS)N)rz_test.py�cr�wzx = 123
)�tempfileZmkdtemp�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
�setUp5s
zPyCompileTestsBase.setUpcCs"t�|j�|jrt�|j�dS)N)�shutilZrmtreer(r2r&r3)r6r	r	r
�tearDownEszPyCompileTestsBase.tearDowncCs<t�|j|j�|�tj�|j��|�tj�|j	��dS)N)
�
py_compile�compiler+r,�
assertTruer&r)�exists�assertFalser0)r6r	r	r
�test_absolute_pathJsz%PyCompileTestsBase.test_absolute_pathc	Csfyt�|jd|j�Wn"ttfk
r:|�d�Yn(X|�t��t�	|j
|j�WdQRXdS)Nz.actualz.need to be able to create a symlink for a file)r&�symlinkr,�NotImplementedError�OSErrorZskipTest�assertRaises�FileExistsErrorr;r<r+)r6r	r	r
�test_do_not_overwrite_symlinksOsz1PyCompileTestsBase.test_do_not_overwrite_symlinksz7requires os.devnull and for it to be a non-regular filec	Cs*|�t��t�|jtj�WdQRXdS)N)rDrEr;r<r+r&�devnull)r6r	r	r
�&test_do_not_overwrite_nonregular_files[sz9PyCompileTestsBase.test_do_not_overwrite_nonregular_filescCs$t�|j�|�tj�|j��dS)N)r;r<r+r=r&r)r>r0)r6r	r	r
�test_cache_pathcsz"PyCompileTestsBase.test_cache_pathc	Csdt�|j��&t�tj�|j�tj�|j	��WdQRX|�
tj�|j	��|�tj�|j
��dS)N)rZ
change_cwdr(r;r<r&r)�basenamer+r,r=r>r?r0)r6r	r	r
�test_cwdgs
zPyCompileTestsBase.test_cwdcCsLt�tj�|j�tj�|j��|�tj�|j��|�	tj�|j
��dS)N)r;r<r&r)�relpathr+r,r=r>r?r0)r6r	r	r
�test_relative_pathnsz%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
�WdQRXWdt�|j|j�XdS)N)r&�statr(�chmod�S_IREADrD�IOErrorr;r<r+r,�st_mode)r6�moder	r	r
�test_exceptions_propagatetsz,PyCompileTestsBase.test_exceptions_propagatec	Cs\tj�tj�t�d�}t���|�tj	|dd��WdQRX|�
tj�tj
�|���dS)Nzbad_coding2.pyF)�doraise)r&r)r*�dirname�__file__rZcaptured_stderrZassertIsNoner;r<r?r>r-r.r/)r6Z
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�}WdQRXtj�d�rvd}nd}|�||�dS)N�rb�testr�r)r;r<r+r,r=r&r)r>r?r0r4r-�_bootstrap_external�
_classify_pyc�read�environ�get�assertEqual)r6�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�WdQRXt�|�|�tj�|��|�tj�|��dS)Nz
foo.bar.pyr#�__pycache__zfoo.bar.{}.pycr$zx = 123
)r&r)r*r(r-r.r/�splitrJrc�format�sys�implementation�	cache_tagr4r5r;r<r=r>r?)r6Z
weird_pathr0r,�head�tailZpenultimate_tailr7r	r	r
�test_double_dot_no_clobber�s
z-PyCompileTestsBase.test_double_dot_no_clobbercCs|�dtj|jdd��dS)Nzopt-2�)�optimize)ZassertInr;r<r+)r6r	r	r
�test_optimization_path�sz)PyCompileTestsBase.test_optimization_pathc	Cs�tj|jtjjd�t|jd��}tj�	|�
�di�}WdQRX|�|d�tj|jtjjd�t|jd��}tj�	|�
�di�}WdQRX|�|d�dS)N)�invalidation_moder[r\r]�)
r;r<r+�PycInvalidationMode�CHECKED_HASHr4r0r-r^r_r`rc�UNCHECKED_HASH)r6rdrer	r	r
�test_invalidation_mode�sz)PyCompileTestsBase.test_invalidation_modeN)rrr r8r:r@rF�unittestZskipIfr&r)r>rG�isfilerHrIrKrM�hasattrrNrrVrZrfrjrerqrorrrxr	r	r	r
r"3s$ 
r"c@seZdZdS)�PyCompileTestsWithSourceEpochN)rrr r	r	r	r
r|�sr|T)�	metaclassrc@seZdZdS)� PyCompileTestsWithoutSourceEpochN)rrr r	r	r	r
r~�sr~F�__main__)r�importlib.utilr-r&r;r9rPrjr%ryr\rrr�typeZTestCaserr"r|r~r�mainr	r	r	r
�<module>s0