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_venv.cpython-310.opt-2.pyc
o

�i�Z�@s6	ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZddlmZmZmZddlZddlZddlmZzddlZWney^dZYnwe�ejejkplejejkd�Zddd�ZGdd	�d	ej �Z!Gd
d�de!�Z"eGdd
�d
e!��Z#e$dkr�e�%�dSdS)�N)�captured_stdout�captured_stderr�
requires_zlib�*skip_if_broken_multiprocessing_synchronize)�can_symlink�EnvironmentVarGuard�rmtree)�patchz:cannot run venv.create from within a venv on this platformcCsBtj|tjtj|d�}|��\}}|jrt�|j|||��||fS)N)�stdout�stderr�encoding)�
subprocess�Popen�PIPE�communicate�
returncode�CalledProcessError)�cmdr�p�out�err�r�+/usr/local/lib/python3.10/test/test_venv.py�check_output%s�
�rc@s@eZdZ	dZdd�Zdd�Zdd�Zdd	�Zd
d�dd
�ZdS)�BaseTesti�cCs�tj�t���|_tjdkrd|_d|_d|_	nd|_ddt
jdd�f|_d	|_	t
j}tj�
|�d
|_t
jdkrLtj�|�rLtj�|�sLd|_dSd
|_dS)N�nt�Scripts��Lib�Include�bin�lib�python%d.%d��include����win32TF)�os�path�realpath�tempfile�mkdtemp�env_dir�name�bindirr!r$�sys�version_info�_base_executable�split�exe�platform�lexists�exists�cannot_link_exe)�self�
executablerrr�setUp4s"


�
�

zBaseTest.setUpcCst|j�dS�N)rr,�r8rrr�tearDownGszBaseTest.tearDownc	Osjt��"}t��}||i|��Wd�n1swYWd�n1s(wY|��|��fSr;)rr�getvalue)r8�func�args�kwargs�output�errorrrr�run_with_captureJs���zBaseTest.run_with_capturecGstjj|jg|�R�Sr;)r'r(�joinr,)r8r@rrr�get_env_filePszBaseTest.get_env_filezutf-8�rcGsBt|j|�d|d��
}|��}Wd�|S1swY|S)N�rrG)�openrF�read)r8rr@�f�resultrrr�get_text_file_contentsSs

��zBaseTest.get_text_file_contentsN)	�__name__�
__module__�__qualname__ZmaxDiffr:r=rDrFrMrrrrr0src	@s@eZdZ	dd�Zdd�Zdd�Zdd�Zed	d
��Ze	j
dkr#dZnd
dddde	jdd�fdde	jdd�dffZdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Ze�e�d!�d"d#��Zed$d%��Ze�e�d!�d&d'��Ze�ejd(kd)�d*d+��Zed,d-��Ze�ejd(kd.�d/d0��Ze�e	j
d1kd2�d3d4��ZdS)5�	BasicTestcGs |j|�}|�tj�|��dSr;)rF�
assertTruer'r(�isdir)r8r@�fnrrrrS[s
zBasicTest.isdircCs$	t|j�|�tj|j�|�|j�|�|j�|j|j�|�	d�}t
�d�dko5tj
dko5tjdk}|rB|�tj�|��n	|�tj�|��|�d�}tj}tj�|�}|�d||�|�	|j|j�}tj�|�s�|�	|j�}td|�td	t�|��|�tj�|�d
|�dS)NZlib64�P��posix�darwin�
pyvenv.cfgz	home = %s�Contents of %r:�    %r�File %r should exist.)rr,rD�venv�createrSr.r$r!rF�struct�calcsizer'r-r/r4rRr(�islink�assertFalser6rMr1�dirname�assertInr3�print�listdir)r8rZ
conditions�datar9r(rT�bdrrr�
test_defaults_s.

�
zBasicTest.test_defaultscCs0tj�|j�d}t|j�t��}|�|j|j�|�	|j�}|�
d�}|�|jd|�|�
d|�t|j�tjdd�}|�|j|j�|�	|j�}|�
d�}|�|jd�|�d|�t|j�tjd	d�}tj�t���}|�|j|j�|�	|j�}|�
d�}|�|jd|�|�d
||�dS)N�rYz(%s) z	prompt = z	My prompt)�promptz(My prompt) zprompt = 'My prompt'
�.zprompt = '%s'
)r'r(r2r,rr]�
EnvBuilderrDr^�ensure_directoriesrM�assertEqualrkZassertNotInrd�basename�getcwd)r8Zenv_name�builder�contextrg�cwdrrr�test_prompt{s.





zBasicTest.test_promptc	s�t��}tjdkrdnd}tj�tj�d}t�	��R}tj�
tj�|||���tjdkr6tj�
tj�������fdd�}|�
|�}td|��
|�|�Wd�n1sWwYWd�dSWd�dS1sowYdS)Nr&rr rjc
s2tj�|d�|d<��|�ddddddg�dS)Nr�-m�pip�installz	--upgradeZ
setuptools)r'r(�normcasero)rrA�Z
expect_exer8rr�pip_cmd_checker�s��z<BasicTest.test_upgrade_dependencies.<locals>.pip_cmd_checkerzvenv.subprocess.check_output)r]rmr/r4r'r(r2r9r*�TemporaryDirectoryryrEr)rnr	Zupgrade_dependencies)r8rrZbin_pathZ
python_exeZfake_env_dirr{Zfake_contextrrzr�test_upgrade_dependencies�s"
�

��"�z#BasicTest.test_upgrade_dependenciescCs�	t|j�|�tj|j�tj�|j|j|j	�}|ddg}d|jfd|jfdt
jfdt
jffD]\}}d||d<t
|�\}}|�|��|���q0dS)N�-c�prefix�exec_prefix�base_prefix�base_exec_prefixzimport sys; print(sys.%s)r#)rr,rDr]r^r'r(rEr.r3r/r�r�rro�strip�encode)r8�envpyrrZexpectedrrrrr�
test_prefixes�s

��zBasicTest.test_prefixesr&))r)rr)r�
site-packages)r )r$)r!r!r"Nr#r�c	Csr	|D]3}tjj|jg|�R�}t�|�tj�||�}t|d��
}|�d�Wd�n1s1wYqdS)N�wb�Still here?)r'r(rEr,�mkdirrI�write)r8�paths�filename�subdirs�drTrKrrr�create_contents�s
���zBasicTest.create_contentsc	Cs�	|�|jd�t�|j�|jD]5}tjj|jg|d�R�}|�tj�	|��t
|d��}|�|��d�Wd�n1sAwYqtj
dd�}|�|j�|jD]}tjj|jg|d�R�}|�tj�	|��qVdS)N�foo)r��rbr�T��clear)r��ENV_SUBDIRSr]r^r,r'r(rErRr6rIrorJrmrb)r8r�rTrKrrrrr�test_overwrite_existing�s 
��
�z!BasicTest.test_overwrite_existingcCsZt�|�D]%}tj�||�}tj�|�stj�|�r t�|�qtj�|�r*t|�qdSr;)	r'rfr(rEra�isfile�removerSr)r8r(rTrrr�clear_directory�s��zBasicTest.clear_directoryc	Cs�|jdd�D]8}tjj|jg|�R�}t|d��
}|�d�Wd�n1s)wY|�tt	ft
j|j�|�|j�qdS)N�r��)
r�r'r(rEr,rIr�ZassertRaises�
ValueError�OSErrorr]r^r�)r8r�rTrKrrr�test_unoverwritable_fails�s��z#BasicTest.test_unoverwritable_failscCs�	dD]Q}tj|d�}|�|j|j�|�|j�|�|j�|j|j�|�	|j|j
�}tj�
|�sH|�	|j�}td|�tdt�|��|�tj�
|�d|�qdS)N�FT)�upgraderZr[r\)r]rmrDr^r,rSr.r$r!rFr3r'r(r6rerfrR)r8r�rrrTrhrrr�test_upgrades�zBasicTest.test_upgradecCsH	dD]\}}tjd|d�}|�|j�|�d�}|�d||�qdS)N))T�true)FZfalseT)r��system_site_packagesrYz"include-system-site-packages = %s
)r]rmr^r,rMrd)r8Zssp�srrrgrrr�test_isolations
�zBasicTest.test_isolationzNeeds symlinkscCsj	dD]/}tjd|d�}|�|j�|�|j|j�}|r2|jr)|�t	j
�|��q|�t	j
�|��qdS)Nr�T�r��symlinks)
r]rmr^r,rFr.r3r7rbr'r(rarR)r8ZuslrrrTrrr�test_symlinking&s��zBasicTest.test_symlinkingcCsd	t|j�|�tj|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)Nr~�!import sys; print(sys.executable))rr,rDr]r^r'r(rEr)r.r3rror�r��r8r�rrrrr�test_executable>s
�
�zBasicTest.test_executablecCsn	t|j�tjddd�}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)NTr�r~r��rr,r]rmr^r'r(rEr)r.r3rror�r��r8rrr�rrrrr�test_executable_symlinksKs
�
�z"BasicTest.test_executable_symlinksrzonly relevant on WindowscCs�	t|j�tj�tj�|j�d�}tjdd�}|�|�tj�||j	d�}tj�||j	|j
�}t|d|j
ddgdd	�\}}|�|�
�d
�dS)NuϼўТλФЙTr�zactivate.bat�&r~zprint(0)ZoemrG�0)rr,r'r(rEr)r]rmr^r.r3rror�)r8r,rr�activater�rrrrr�test_unicode_in_batch_fileYs


�z$BasicTest.test_unicode_in_batch_filecCsj	t�t|j�|�tj|j�tj�tj�	|j�|j
|j�}t|ddg�\}}|�
|��d���dS)Nr~zrfrom multiprocessing import Pool; pool = Pool(1); print(pool.apply_async("Python".lower).get(3)); pool.terminate()Zpython)rrr,rDr]r^r'r(rEr)r.r3rror�r�r�rrr�test_multiprocessingjs
�
�zBasicTest.test_multiprocessingznot relevant on WindowscCs�t�d�}|dur|�d�t|j�tjdd�}|�|j�tj	�
|j|jd�}tj	�
|jd�}t|d��}|�
d|�d	��Wd�n1sJwYt||g�\}}|�|d
���|�|d
���dS)N�bashzbash required for this testTr�r�ztest_strict.sh�wzset -euo pipefail
source z
deactivate
�)�shutil�whichZskipTestrr,r]rmr^r'r(rEr.rIr�rror�)r8r�rrr�Ztest_scriptrKrrrrr�%test_deactivate_with_strict_bash_optss 


��z/BasicTest.test_deactivate_with_strict_bash_optsrXzonly relevant on macOScCsft|j�t��}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�d���dS)Nr~z5import os; print("__PYVENV_LAUNCHER__" in os.environ)�Falser�r�rrr�test_macos_env�s
�
�zBasicTest.test_macos_env) rNrOrPrSrirur}�requireVenvCreater�r/r4r�r0r�r�r�r�r�r��unittest�
skipUnlessrr�r�r�r'r-r�r�ZskipIfr�r�rrrrrQXsH

�	






rQc@s^eZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�Zej	dd��Z
e�e
d
�e�dd���ZdS)�
EnsurePipTestcCsdtj�tj�|j�|j|j�}t|ddg�\}}|�d�}|�	|d�|�d�}|�	|�
�d�dS)Nr~z1try:
 import pip
except ImportError:
 print("OK")�latin-1r�ZOK)r'r(rEr)r,r.r3r�decoderor�r�rrr�assert_pip_not_installed�s�
�

z&EnsurePipTest.assert_pip_not_installedcCs&t|j�|�tj|j�|��dSr;�rr,rDr]r^r�r<rrr�test_no_pip_by_default�s
z$EnsurePipTest.test_no_pip_by_defaultcCs*t|j�|jtj|jdd�|��dS)NF)�with_pipr�r<rrr�test_explicit_no_pip�s
z"EnsurePipTest.test_explicit_no_pipcCsTttjd��}|�|��d�Wd�n1swY|�tj�tj��dS)Nr�r�)rIr'�devnullrorJrRr(r6)r8rKrrr�test_devnull�s�zEnsurePipTest.test_devnullcCs�t|j�t���}d|d<d|d<t���f}||d<d}d}d}|fD]1\}}tj�||�}	t�|	�tj�|	|�}
t	|
d	��
}|�
|�Wd�n1sOwYq#|���|jt
j|j|d
d�Wd�n1sowYWd�n1s~wYWd�n1s�wYtj�tj�|j�|j|j�}t|dd
ddddddg	�\}
}|�d�}|�|d�|
�d�}
d�t���}|�|
dt|��|�t�|j��d�}|�||
�t��/}|���d|d<t|dd
dddddg�\}
}Wd�n	1�swYWd�n	1�swY|�d�}tjdd|tjd�}|�|��d�|
�d�}
|�d|
�|�d|
�|�sN|��dSdS)N�ignoreZPYTHONWARNINGS�1ZPIP_NO_INSTALL�HOMEz[global]
no-install=1)rwzpip.ini)z.pipzpip.confr�T)r�r�z-Wzignore::DeprecationWarningzignore::ImportWarningz-Irvrwz	--versionr�r�zpip {}zensurepip._uninstallzl^(WARNING: )?The directory .* or its parent directory is not owned or is not writable by the current user.*$)�flagszSuccessfully uninstalled pipz#Successfully uninstalled setuptools) rr,rr*r|r'r(rEr�rIr��nicer_errorrDr]r^r)r.r3rr�ro�format�	ensurepip�version�len�fsencoderd�re�sub�	MULTILINE�rstripr�)r8r��envvarsZhome_dirZ
bad_configZwin_locationZposix_locationrcZfname�dirpathZfpathrKr�rrZexpected_versionr,rrr�do_test_with_pip�s|


��
������#
�


����
�
�zEnsurePipTest.do_test_with_pipc
csx�	zdVWdStjy;}z&|jpdjdd�}|jpdjdd�}|�|�d|�d|���WYd}~dSd}~ww)Nr��replace)�errorsz

**Subprocess Output**
z

**Subprocess Error**
)r
rrBr�rZfail)r8�excrrrrrr�s ������zEnsurePipTest.nicer_errorzpip requires ctypescCs|�d�|�d�dS)NFT)r�r<rrr�
test_with_pip/s
zEnsurePipTest.test_with_pipN)rNrOrPr�r�r�r�r��
contextlib�contextmanagerr�r�r��ctypesrr�rrrrr��s

Y

r��__main__r;)&r�r�r'Zos.pathr�r�r_r
r/r*Ztest.supportrrrrZtest.support.os_helperrrrr�r]Z
unittest.mockr	r��ImportErrorr�rr�r1r9r�rZTestCaserrQr�rN�mainrrrr�<module>sJ�
�
(H�