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: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_venv.cpython-37.opt-2.pyc
B

��g�O�@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
mZmZddlZddlZddlZyddlZWnek
r�dZYnXe�eed�p�ejejkd�Zddd�ZGdd�dej�ZGd	d
�d
e�ZeGdd�de��Zed
k�re� �dS)�N)�captured_stdout�captured_stderr�
requires_zlib�can_symlink�EnvironmentVarGuard�rmtree�_base_executablez:cannot run venv.create from within a venv on this platformcCsBtj|tjtj|d�}|��\}}|jr:t�|j|||��||fS)N)�stdout�stderr�encoding)�
subprocess�Popen�PIPEZcommunicate�
returncode�CalledProcessError)�cmdr�p�out�err�r�*/usr/local/lib/python3.7/test/test_venv.py�check_output#src@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�BaseTesti�cCs�tj�t���|_tjdkr0d|_d|_d|_	n$d|_ddt
jdd�f|_d	|_	tt
d
t
j
�}tj�|�d|_t
jdkr�tj�|�r�tj�|�s�d
|_nd|_dS)N�nt�Scripts)�Lib�Include�bin�libzpython%d.%d��includer����win32TF)�os�path�realpath�tempfileZmkdtemp�env_dir�name�bindirrr �sys�version_info�getattr�
executable�split�exe�platform�lexists�exists�cannot_link_exe)�selfr-rrr�setUp2s

zBaseTest.setUpcCst|j�dS)N)rr')r4rrr�tearDownEszBaseTest.tearDownc
Os>t��"}t��}|||�WdQRXWdQRX|��|��fS)N)rr�getvalue)r4�func�args�kwargs�output�errorrrr�run_with_captureHszBaseTest.run_with_capturecGstjj|jf|��S)N)r#r$�joinr')r4r9rrr�get_env_fileNszBaseTest.get_env_filec	Gs(t|j|�d��}|��}WdQRX|S)N�r)�openr?�read)r4r9�f�resultrrr�get_text_file_contentsQszBaseTest.get_text_file_contentsN)	�__name__�
__module__�__qualname__ZmaxDiffr5r6r=r?rErrrrr.src	@s6eZdZdd�Zdd�Zdd�Zedd��Zej	d	kr<d
Z
n4ddd
ddejdd�fddejdd�dffZ
dd�Zdd�Z
dd�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-d.��Ze�ej	d/kd0�d1d2��ZdS)3�	BasicTestcGs |j|�}|�tj�|��dS)N)r?�
assertTruer#r$�isdir)r4r9�fnrrrrKYs
zBasicTest.isdircCs,t|j�|�tj|j�|�|j�|�|j�|j|j�|�	d�}t
�d�dkohtj
dkohtjdk}|r�|�tj�|��n|�tj�|��|�d�}ttdtj�}tj�|�}|�d||�|�	|j|j�}tj�|��s|�	|j�}td	|�td
t�|��|�tj�|�d|�dS)NZlib64�P��posix�darwinz
pyvenv.cfgrz	home = %szContents of %r:z    %rzFile %r should exist.)rr'r=�venv�createrKr)r rr?�struct�calcsizer#r(r*r0rJr$�islink�assertFalser2rEr,r-�dirname�assertInr/�print�listdir)r4rZ
conditions�datar-r$rL�bdrrr�
test_defaults]s*



zBasicTest.test_defaultscCsbtj�|j�d}t��}|�|j�}|�|jd|�tjdd�}|�|j�}|�|jd�dS)N�z(%s) z	My prompt)�promptz(My prompt) )	r#r$r.r'rQ�
EnvBuilderZensure_directories�assertEqualr_)r4Zenv_name�builder�contextrrr�test_promptyszBasicTest.test_promptcCs�t|j�|�tj|j�tj�|j|j|j	�}|ddg}x\d|jfd|jfdt
jfdt
jffD]4\}}d||d<t
|�\}}|�|��|���q`WdS)Nz-c�prefix�base_prefix�base_exec_prefixzimport sys; print(sys.%s)r)rr'r=rQrRr#r$r>r)r/r*rfrgrra�strip�encode)r4�envpyrreZexpectedrrrrr�
test_prefixes�s

zBasicTest.test_prefixesr"))r)r)r)rz
site-packages)r)r )rrzpython%d.%dNrz
site-packagesc
Cs^xX|D]P}tjj|jf|��}t�|�tj�||�}t|d��}|�d�WdQRXqWdS)N�wbsStill here?)r#r$r>r'�mkdirrA�write)r4�paths�filename�subdirs�drLrCrrr�create_contents�s

zBasicTest.create_contentsc
Cs�|�|jd�t�|j�x^|jD]T}tjj|jf|d��}|�tj�	|��t
|d��}|�|��d�WdQRXq"Wtj
dd�}|�|j�x8|jD].}tjj|jf|d��}|�tj�	|��q�WdS)N�foo)rt�rbsStill here?T)�clear)rs�ENV_SUBDIRSrQrRr'r#r$r>rJr2rArarBr`rV)r4rqrLrCrbrrr�test_overwrite_existing�sz!BasicTest.test_overwrite_existingcCs^xXt�|�D]J}tj�||�}tj�|�s6tj�|�rBt�|�qtj�|�rt|�qWdS)N)	r#rZr$r>rU�isfile�removerKr)r4r$rLrrr�clear_directory�szBasicTest.clear_directoryc
Csrxl|jdd�D]Z}tjj|jf|��}t|d��}|�d�WdQRX|�tt	ft
j|j�|�|j�qWdS)N�rl�)
rwr#r$r>r'rArnZassertRaises�
ValueError�OSErrorrQrRr{)r4rorLrCrrr�test_unoverwritable_fails�sz#BasicTest.test_unoverwritable_failscCs�x�dD]�}tj|d�}|�|j|j�|�|j�|�|j�|j|j�|�	|j|j
�}tj�
|�s�|�	|j�}td|�tdt�|��|�tj�
|�d|�qWdS)N)FT)�upgradezContents of %r:z    %rzFile %r should exist.)rQr`r=rRr'rKr)r rr?r/r#r$r2rYrZrJ)r4r�rbrLr\rrr�test_upgrade�s
zBasicTest.test_upgradecCsJxDdD]<\}}tjd|d�}|�|j�|�d�}|�d||�qWdS)N))T�true)FZfalseT)rv�system_site_packagesz
pyvenv.cfgz"include-system-site-packages = %s
)rQr`rRr'rErX)r4Zssp�srbr[rrr�test_isolation�s

zBasicTest.test_isolationzNeeds symlinkscCslxfdD]^}tjd|d�}|�|j�|�|j|j�}|r|jrR|�t	j
�|��q|�t	j
�|��qWdS)N)FTT)rv�symlinks)
rQr`rRr'r?r)r/r3rVr#r$rUrJ)r4ZuslrbrLrrr�test_symlinking�s
zBasicTest.test_symlinkingcCsbt|j�|�tj|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)Nz-cz!import sys; print(sys.executable))rr'r=rQrRr#r$r>r%r)r/rrarhri)r4rjrrrrr�test_executable
s
zBasicTest.test_executablecCslt|j�tjddd�}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)NT)rvr�z-cz!import sys; print(sys.executable))rr'rQr`rRr#r$r>r%r)r/rrarhri)r4rbrjrrrrr�test_executable_symlinkss
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ϼўТλФЙT)rvzactivate.bat�&z-czprint(0)Zoem)r�0)rr'r#r$r>r%rQr`rRr)r/rrarh)r4r'rb�activaterjrrrrr�test_unicode_in_batch_file(s

z$BasicTest.test_unicode_in_batch_filecCsbt|j�|�tj|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�d���dS)Nz-czrfrom multiprocessing import Pool; pool = Pool(1); print(pool.apply_async("Python".lower).get(3)); pool.terminate()Zpython)rr'r=rQrRr#r$r>r%r)r/rrarhri)r4rjrrrrr�test_multiprocessing9s
zBasicTest.test_multiprocessingznot relevant on Windowsc	Cs�t�d�}|dkr|�d�t|j�tjdd�}|�|j�tj	�
|j|jd�}tj	�
|jd�}t|d��}|�
d|�d	��WdQRXt||g�\}}|�|d
���|�|d
���dS)N�bashzbash required for this testT)rvr�ztest_strict.sh�wzset -euo pipefail
source z
deactivate
�)�shutilZwhichZskipTestrr'rQr`rRr#r$r>r)rArnrrari)r4r�rbr�Ztest_scriptrCrrrrr�%test_deactivate_with_strict_bash_optsIs


z/BasicTest.test_deactivate_with_strict_bash_optsrPzonly relevant on macOScCsft|j�t��}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�d���dS)Nz-cz5import os; print("__PYVENV_LAUNCHER__" in os.environ)�False)rr'rQr`rRr#r$r>r%r)r/rrarhri)r4rbrjrrrrr�test_macos_env\s
zBasicTest.test_macos_env)rFrGrHrKr]rd�requireVenvCreaterkr*r0rwr+rsrxr{r�r�r��unittest�
skipUnlessrr�r�r�r#r(r�r�ZskipIfr�r�rrrrrIVs0
	

rIc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Ze�	e
d�edd
���ZdS)�
EnsurePipTestcCsdtj�tj�|j�|j|j�}t|ddg�\}}|�d�}|�	|d�|�d�}|�	|�
�d�dS)Nz-cz1try:
 import pip
except ImportError:
 print("OK")zlatin-1r�ZOK)r#r$r>r%r'r)r/r�decoderarh)r4rjrrrrr�assert_pip_not_installedks

z&EnsurePipTest.assert_pip_not_installedcCs&t|j�|�tj|j�|��dS)N)rr'r=rQrRr�)r4rrr�test_no_pip_by_defaultxs
z$EnsurePipTest.test_no_pip_by_defaultcCs*t|j�|jtj|jdd�|��dS)NF)�with_pip)rr'r=rQrRr�)r4rrr�test_explicit_no_pip}s
z"EnsurePipTest.test_explicit_no_pipc	Csdttjd��}|�|��d�WdQRXtj��dkrL|�tj�tj��n|�	tj�tj��dS)Nrur}Znul)
rAr#�devnullrarB�lowerrVr$r2rJ)r4rCrrr�test_devnull�s
zEnsurePipTest.test_devnullcCs:t|j�t���}d|d<d|d<t����}||d<d}d}d}xX|fD]N\}}tj�||�}	t�|	�tj�|	|�}
t	|
d	��}|�
|�WdQRXqHWy|jtj
|j|d
d�WnHtjk
r�}z(|jjdd
�}
d}|�|�||
��Wdd}~XYnXWdQRXWdQRXtj�tj�|j�|j|j�}t|ddddddg�\}}|�d�}|�|d�|�d�}d�t���}|�|dt|��|�t�|j��d�}|�||�t��}t|dddddg�\}}WdQRX|�d�}tjdd|tj d�}|�|�!�d�|�d�}|�d|�|�d|�|�s6|�"�dS)N�eZPYTHONWARNINGS�1ZPIP_NO_INSTALL�HOMEz[global]
no-install=1)�pipzpip.ini)z.pipzpip.confr�T)r�r��replace)�errorsz{}

**Subprocess Output**
{}z-Wzignore::DeprecationWarningz-Iz-mr�z	--versionzlatin-1r�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&ZTemporaryDirectoryr#r$r>rmrArnr=rQrRrrr;r�Zfail�formatr%r)r/rra�	ensurepip�version�len�fsencoderX�re�sub�	MULTILINE�rstripr�)r4r��envvarsZhome_dirZ
bad_configZwin_locationZposix_locationrWZfname�dirpathZfpathrC�excZdetails�msgrjrrZexpected_versionr'rrr�do_test_with_pip�s^


8




zEnsurePipTest.do_test_with_pipzpip requires ctypescCs|�d�|�d�dS)NFT)r�)r4rrr�
test_with_pip�s
zEnsurePipTest.test_with_pipN)
rFrGrHr�r�r�r�r�r�r��ctypesrr�rrrrr�hs
Z
r��__main__)N)!r�r#Zos.pathr�r�rSrr*r&Ztest.supportrrrrrrZ	threadingr�rQr��ImportErrorr��hasattrrerfr�rZTestCaserrIr�rF�mainrrrr�<module>s< 



(