Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_venv.cpython-310.pyc
o

�9ji�@s@dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZmZmZddlmZmZmZddlZddlZddlmZzddlZWneycdZYnwe�e	je	jkpqe	je	jkd�Z ddd�Z!Gd	d
�d
ej"�Z#Gdd�de#�Z$e Gd
d�de#��Z%e&dkr�e�'�dSdS)z|
Test harness for the venv module.

Copyright (C) 2011-2012 Vinay Sajip.
Licensed to the PSF under a contributor agreement.
�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/lib/python3.10/test/test_venv.py�check_output&s�
�rc@sJeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�d
d�Z	dd�Z
dS)�BaseTestzBase class for venv tests.i�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�setUp5s"


�
�

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

��zBaseTest.get_text_file_contentscCs(|�|�s|�d|�d|���dSdS)NzString z does not end with )�endswith�fail)r8�string�tailrrr�assertEndsWithYs
�zBaseTest.assertEndsWithN)�__name__�
__module__�__qualname__�__doc__�maxDiffr:r=rDrFrMrRrrrrr1src	@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	e
jdkr$d
Znddddde
j
dd�fdde
j
dd�dffZdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Ze�e�d"�d#d$��Zed%d&��Ze�e�d"�d'd(��Ze�ejd)kd*�d+d,��Ze�ejd)kd*�d-d.��Ze�ejd)kd/�d0d1��Ze�ejd)kd/�d2d3��Z ed4d5��Z!e�ejd)kd6�d7d8��Z"e�e
jd9kd:�d;d<��Z#dS)=�	BasicTestzTest venv module functionality.cGs |j|�}|�tj�|��dSr;)rF�
assertTruer'r(�isdir)r8r@�fnrrrrZ`s
zBasicTest.isdircCs"t|j�|�tj|j�|�|j�|�|j�|j|j�|�	d�}t
�d�dko4tj
dko4tjdk}|rA|�tj�|��n	|�tj�|��|�d�}tj}tj�|�}|�d||�|�	|j|j�}tj�|�s�|�	|j�}td|�td	t�|��|�tj�|�d
|�dS)zB
        Test the create function with default arguments.
        �lib64�P��posix�darwin�
pyvenv.cfgz	home = %s�Contents of %r:�    %r�File %r should exist.N)rr,rD�venv�createrZr.r$r!rF�struct�calcsizer'r-r/r4rYr(�islink�assertFalser6rMr1�dirname�assertInr3�print�listdir)r8r�
conditions�datar9r(r[�bdrrr�
test_defaultsds,

�
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�raz(%s) z	prompt = z	My prompt)�promptz(My prompt) zprompt = 'My prompt'
�.zprompt = '%s'
)r'r(r2r,rre�
EnvBuilderrDrf�ensure_directoriesrM�assertEqualrt�assertNotInrl�basename�getcwd)r8�env_name�builder�contextrp�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 rsc
s2tj�|d�|d<��|�ddddddg�dS)Nr�-m�pip�installz	--upgrade�
setuptools)r'r(�normcaserx)rrA��
expect_exer8rr�pip_cmd_checker�s��z<BasicTest.test_upgrade_dependencies.<locals>.pip_cmd_checkerzvenv.subprocess.check_output)rervr/r4r'r(r2r9r*�TemporaryDirectoryr�rEr)rwr	�upgrade_dependencies)r8r}�bin_path�
python_exe�fake_env_dirr��fake_contextrr�r�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
|�\}}|�|��|���q/dS)	z>
        Test that the prefix values are as expected.
        �-cN�prefix�exec_prefix�base_prefix�base_exec_prefixzimport sys; print(sys.%s)r#)rr,rDrerfr'r(rEr.r3r/r�r�rrx�strip�encode)r8�envpyrr��expectedrrrrr�
test_prefixes�s

��zBasicTest.test_prefixesr&))r)rr)r�
site-packages)r )r$)r!r!r"Nr#r�c	Csp|D]3}tjj|jg|�R�}t�|�tj�||�}t|d��
}|�d�Wd�n1s0wYqdS)zn
        Create some files in the environment which are unrelated
        to the virtual environment.
        �wb�Still here?N)r'r(rEr,�mkdirrI�write)r8�paths�filename�subdirs�dr[rKrrr�create_contents�s
���zBasicTest.create_contentsc	Cs�|�|jd�t�|j�|jD]5}tjj|jg|d�R�}|�tj�	|��t
|d��}|�|��d�Wd�n1s@wYqtj
dd�}|�|j�|jD]}tjj|jg|d�R�}|�tj�	|��qUdS)zE
        Test creating environment in an existing directory.
        �foo)r��rbr�NT��clear)r��ENV_SUBDIRSrerfr,r'r(rErYr6rIrxrJrvrj)r8r�r[rKr}rrr�test_overwrite_existing�s
��
�z!BasicTest.test_overwrite_existingcCsZt�|�D]%}tj�||�}tj�|�stj�|�r t�|�qtj�|�r*t|�qdSr;)	r'rnr(rEri�isfile�removerZr)r8r(r[rrr�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��assertRaises�
ValueError�OSErrorrerfr�)r8r�r[rKrrr�test_unoverwritable_failss��z#BasicTest.test_unoverwritable_failscCs�dD]Q}tj|d�}|�|j|j�|�|j�|�|j�|j|j�|�	|j|j
�}tj�
|�sG|�	|j�}td|�tdt�|��|�tj�
|�d|�qdS)zC
        Test upgrading an existing environment directory.
        �FT)�upgraderbrcrdN)rervrDrfr,rZr.r$r!rFr3r'r(r6rmrnrY)r8r�r}r[rqrrr�test_upgrades�zBasicTest.test_upgradecCsFdD]\}}tjd|d�}|�|j�|�d�}|�d||�qdS)z:
        Test isolation from system site-packages
        ))T�true)F�falseT)r��system_site_packagesraz"include-system-site-packages = %s
N)rervrfr,rMrl)r8�ssp�sr}rprrr�test_isolation!s
�zBasicTest.test_isolationzNeeds symlinkscCshdD]/}tjd|d�}|�|j�|�|j|j�}|r1|jr(|�t	j
�|��q|�t	j
�|��qdS)z3
        Test symlinking works as expected
        r�T�r��symlinksN)
rervrfr,rFr.r3r7rjr'r(rirY)r8�uslr}r[rrr�test_symlinking+s��zBasicTest.test_symlinkingcCsbt|j�|�tj|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)�D
        Test that the sys.executable value is as expected.
        r��!import sys; print(sys.executable)N)rr,rDrerfr'r(rEr)r.r3rrxr�r��r8r�rrrrr�test_executableCs
�
�zBasicTest.test_executablecCslt|j�tjddd�}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)r�Tr�r�r�N�rr,rervrfr'r(rEr)r.r3rrxr�r��r8r}r�rrrrr�test_executable_symlinksPs
�
�z"BasicTest.test_executable_symlinksrz&contains invalid characters on WindowscCst|j�t�d�}|dur|�d�d}tj�tj�|j�|�}t	j
dd�}|�|�tj�||jd�}tj�|jd�}t
|d	��}|�d
t�|��d��Wd�n1sYwYt||g�\}}	|��}
|�|��|
dv�|�|
d
|���dS)zK
        Test that the template strings are quoted properly (bash)
        �bashN�bash required for this test�
"';&&$e|'"Tr��activateztest_special_chars.sh�w�source �r
python -c 'import sys; print(sys.executable)'
python -c 'import os; print(os.environ["VIRTUAL_ENV"])'
deactivate
rrs�rr,�shutil�which�skipTestr'r(rEr)rervrfr.rIr��shlex�quoter�
splitlinesrYr�rR)r8r�r|r,r}r��test_scriptrKrr�linesrrr�test_special_chars_bash_s"



�z!BasicTest.test_special_chars_bashcCst|j�t�d�pt�d�}|dur|�d�d}tj�tj�|j�|�}t	j
dd�}|�|�tj�||jd�}tj�|jd	�}t
|d
��}|�dt�|��d��Wd�n1s^wYt||g�\}}	|��}
|�|��|
d
v�|�|
d|���dS)zJ
        Test that the template strings are quoted properly (csh)
        �tcsh�cshNzcsh required for this testr�Tr�zactivate.cshztest_special_chars.cshr�r�r�rrsr�)r8r�r|r,r}r�r�rKrrr�rrr�test_special_chars_cshys"


�z BasicTest.test_special_chars_cshzonly relevant on Windowsc

Cs�t|j�d}tj�tj�|j�|�}tjdd�}|�|�tj�||j	d�}tj�|jd�}t
|d��}|�d|�d|j�d	|j�d
��Wd�n1sPwYt
|g�\}}|��}	|�|��|	dv�|�|	d
|���dS)zO
        Test that the template strings are quoted properly on Windows
        z'&&^$eTr��activate.batztest_special_chars.batr�z@echo off
"z" & z* -c "import sys; print(sys.executable)" & z> -c "import os; print(os.environ['VIRTUAL_ENV'])" & deactivateNrrs)rr,r'r(rEr)rervrfr.rIr�r3rr�rYr�rR)
r8r|r,r}r��
test_batchrKrrr�rrr�test_special_chars_windows�s(

����z$BasicTest.test_special_chars_windowscCs�t|j�tj�tj�|j�d�}tjdd�}|�|�tj�||j	d�}tj�||j	|j
�}t|d|j
ddgdd	�\}}|�|�
�d
�dS)z0
        Test handling of Unicode paths
        uϼўТλФЙTr�r��&r�zprint(0)�oemrG�0N)rr,r'r(rEr)rervrfr.r3rrxr�)r8r,r}r�r�rrrrr�test_unicode_in_batch_file�s


�z$BasicTest.test_unicode_in_batch_filecCsht�t|j�|�tj|j�tj�tj�	|j�|j
|j�}t|ddg�\}}|�
|��d���dS)zA
        Test that the multiprocessing is able to spawn.
        r�zrfrom multiprocessing import Pool; pool = Pool(1); print(pool.apply_async("Python".lower).get(3)); pool.terminate()�pythonN)rrr,rDrerfr'r(rEr)r.r3rrxr�r�r�rrr�test_multiprocessing�s
�
�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)Nr�r�Tr�r�ztest_strict.shr�zset -euo pipefail
source z
deactivate
�)r�r�r�rr,rervrfr'r(rEr.rIr�rrxr�)r8r�r}r�r�rKrrrrr�%test_deactivate_with_strict_bash_opts�s 


��z/BasicTest.test_deactivate_with_strict_bash_optsr`zonly 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)$rSrTrUrVrZrrr�r��requireVenvCreater�r/r4r�r0r�r�r�r�r�r��unittest�
skipUnlessrr�r�r��skipIfr'r-r�r�r�r�r�r�r�rrrrrX]sT

�	









rXc@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	j
dd
��Ze�
ed�e�dd���ZdS)�
EnsurePipTestz%Test venv module installation of pip.cCsdtj�tj�|j�|j|j�}t|ddg�\}}|�d�}|�	|d�|�d�}|�	|�
�d�dS)Nr�z1try:
 import pip
except ImportError:
 print("OK")�latin-1r��OK)r'r(rEr)r,r.r3r�decoderxr�r�rrr�assert_pip_not_installed�s�
�

z&EnsurePipTest.assert_pip_not_installedcCs&t|j�|�tj|j�|��dSr;�rr,rDrerfr�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_pips
z"EnsurePipTest.test_explicit_no_pipcCsTttjd��}|�|��d�Wd�n1swY|�tj�tj��dS)Nr�r�)rIr'�devnullrxrJrYr(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�ignore�PYTHONWARNINGS�1�PIP_NO_INSTALL�HOMEz[global]
no-install=1)r�zpip.ini)z.pipzpip.confr�T)r�r�z-Wzignore::DeprecationWarningzignore::ImportWarningz-Ir�r�z	--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_errorrDrerfr)r.r3rr�rx�format�	ensurepip�version�len�fsencoderl�re�sub�	MULTILINE�rstripr�)r8r��envvars�home_dir�
bad_config�win_location�posix_locationrk�fname�dirpath�fpathrKr�rr�expected_versionr,rrr�do_test_with_pips|


��
������#
�


����
�
�zEnsurePipTest.do_test_with_pipc
csv�zdVWdStjy:}z&|jpdjdd�}|jpdjdd�}|�|�d|�d|���WYd}~dSd}~ww)z�
        Capture output from a failed subprocess for easier debugging.

        The output this handler produces can be a little hard to read,
        but at least it has all the details.
        Nr��replace)�errorsz

**Subprocess Output**
z

**Subprocess Error**
)r
rrBr�rrO)r8�excrrrrrr�ls������zEnsurePipTest.nicer_errorzpip requires ctypescCs|�d�|�d�dS)NFT)rr<rrr�
test_with_pip�s
zEnsurePipTest.test_with_pipN)rSrTrUrVr�r�r�r�r�
contextlib�contextmanagerr�r�r��ctypesrrrrrrr��s

Y

r��__main__r;)(rVrr�r'�os.pathrr�rgr
r/r*r��test.supportrrrr�test.support.os_helperrrrr�re�
unittest.mockr	r�ImportErrorr�r�r�r1r9r�r�TestCaserrXr�rS�mainrrrr�<module>sN�
�
,�

Youez - 2016 - github.com/yon3zu
LinuXploit