Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.191.8.183
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_venv.cpython-310.pyc
o

abY�@s0dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZddlmZmZmZddlZddlZddlmZzddlZWney[dZYnwe�ejejkpiejejkd�Zddd�ZGd	d
�d
ej �Z!Gdd�de!�Z"eGd
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�7/usr/local/python-3.10/lib/python3.10/test/test_venv.py�check_output$s�
�rc@sBeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�d
d�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�setUp3s"


�
�

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

��zBaseTest.get_text_file_contentsN)
�__name__�
__module__�__qualname__�__doc__ZmaxDiffr:r=rDrFrMrrrrr/src	@sBeZdZdZdd�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,��Zed-d.��Ze�ejd)kd/�d0d1��Ze�e
jd2kd3�d4d5��Z dS)6�	BasicTestzTest venv module functionality.cGs |j|�}|�tj�|��dSr;)rF�
assertTruer'r(�isdir)r8r@�fnrrrrTZs
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.
        Zlib64�P��posix�darwin�
pyvenv.cfgz	home = %s�Contents of %r:�    %r�File %r should exist.N)rr,rD�venv�createrTr.r$r!rF�struct�calcsizer'r-r/r4rSr(�islink�assertFalser6rMr1�dirname�assertInr3�print�listdir)r8rZ
conditions�datar9r(rU�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�rZz(%s) z	prompt = z	My prompt)�promptz(My prompt) zprompt = 'My prompt'
�.zprompt = '%s'
)r'r(r2r,rr^�
EnvBuilderrDr_�ensure_directoriesrM�assertEqualrlZassertNotInre�basename�getcwd)r8Zenv_name�builder�contextrh�cwdrrr�test_promptzs.





zBasicTest.test_promptc	s�t��}tjdkrdnd}tj�tj�d}t�	��R}tj�
tj�|||���tjdkr6tj�
tj�������fdd�}|�
|�}td|��
|�|�Wd�n1sWwYWd�dSWd�dS1sowYdS)Nr&rr rkc
s2tj�|d�|d<��|�ddddddg�dS)Nr�-m�pip�installz	--upgradeZ
setuptools)r'r(�normcaserp)r�Z
expect_exer8rr�pip_cmd_checker�s��z<BasicTest.test_upgrade_dependencies.<locals>.pip_cmd_checkerzvenv.subprocess.check_call)r^rnr/r4r'r(r2r9r*�TemporaryDirectoryrzrEr)ror	Zupgrade_dependencies)r8rsZbin_pathZ
python_exeZfake_env_dirr|Z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,rDr^r_r'r(rEr.r3r/r�r�rrp�strip�encode)r8�envpyrr�Zexpectedrrrrr�
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�drUrKrrr�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_SUBDIRSr^r_r,r'r(rErSr6rIrprJrnrc)r8r�rUrKrsrrr�test_overwrite_existing�s
��
�z!BasicTest.test_overwrite_existingcCsZt�|�D]%}tj�||�}tj�|�stj�|�r t�|�qtj�|�r*t|�qdSr;)	r'rgr(rErb�isfile�removerTr)r8r(rUrrr�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�rUrKrrr�test_unoverwritable_fails�s��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)�upgrader[r\r]N)r^rnrDr_r,rTr.r$r!rFr3r'r(r6rfrgrS)r8r�rsrUrirrr�test_upgrades�zBasicTest.test_upgradecCsFdD]\}}tjd|d�}|�|j�|�d�}|�d||�qdS)z:
        Test isolation from system site-packages
        ))T�true)FZfalseT)r��system_site_packagesrZz"include-system-site-packages = %s
N)r^rnr_r,rMre)r8Zssp�srsrhrrr�test_isolations
�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)
r^rnr_r,rFr.r3r7rcr'r(rbrS)r8ZuslrsrUrrr�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,rDr^r_r'r(rEr)r.r3rrpr�r��r8r�rrrrr�test_executable=s
�
�zBasicTest.test_executablecCslt|j�tjddd�}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)r�Tr�rr�N�rr,r^rnr_r'r(rEr)r.r3rrpr�r��r8rsr�rrrrr�test_executable_symlinksJs
�
�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)z0
        Test handling of Unicode paths
        uϼўТλФЙTr�zactivate.bat�&rzprint(0)ZoemrG�0N)rr,r'r(rEr)r^rnr_r.r3rrpr�)r8r,rs�activater�rrrrr�test_unicode_in_batch_fileXs


�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.
        rzrfrom multiprocessing import Pool; pool = Pool(1); print(pool.apply_async("Python".lower).get(3)); pool.terminate()ZpythonN)rrr,rDr^r_r'r(rEr)r.r3rrpr�r�r�rrr�test_multiprocessingis
�
�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^rnr_r'r(rEr.rIr�rrpr�)r8r�rsr�Ztest_scriptrKrrrrr�%test_deactivate_with_strict_bash_opts~s 


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

�	






rRc@sReZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	�
ed�e�d
d���Z
dS)�
EnsurePipTestz%Test venv module installation of pip.cCsdtj�tj�|j�|j|j�}t|ddg�\}}|�d�}|�	|d�|�d�}|�	|�
�d�dS)Nrz1try:
 import pip
except ImportError:
 print("OK")�latin-1r�ZOK)r'r(rEr)r,r.r3r�decoderpr�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'�devnullrprJrSr(r6)r8rKrrr�test_devnull�s�zEnsurePipTest.test_devnullcCs�t|j�t���}d|d<d|d<t���z}||d<d}d}d}|fD]1\}}tj�||�}	t�|	�tj�|	|�}
t	|
d	��
}|�
|�Wd�n1sOwYq#z
|jtj
|j|d
d�Wn%tjy�}z|jjdd
�}
d}|�|�||
��WYd}~nd}~wwWd�n1s�wYWd�n1s�wYtj�tj�|j�|j|j�}t|ddddddddg	�\}}|�d�}|�|d�|�d�}d�t���}|�|dt|��|�t�|j��d�}|�||�t��}d|d<t|dddddddg�\}}Wd�n	1�swY|�d�}tjdd|tj d�}|�|�!�d�|�d�}|�d|�|�d|�|�sM|�"�dSdS)N�ignoreZPYTHONWARNINGS�1ZPIP_NO_INSTALL�HOMEz[global]
no-install=1)rxzpip.ini)z.pipzpip.confr�T)r�r��replace)�errorsz{}

**Subprocess Output**
{}z-Wzignore::DeprecationWarningzignore::ImportWarningz-Irwrxz	--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�rDr^r_r
rrBr�Zfail�formatr)r.r3rrp�	ensurepip�version�len�fsencodere�re�sub�	MULTILINE�rstripr�)r8r��envvarsZhome_dirZ
bad_configZwin_locationZposix_locationrdZfname�dirpathZfpathrK�excZdetails�msgr�rrZexpected_versionr,rrr�do_test_with_pip�s�


��
�������)
�

��

�
�zEnsurePipTest.do_test_with_pipzpip requires ctypescCs|�d�|�d�dS)NFT)r�r<rrr�
test_with_pip s
zEnsurePipTest.test_with_pipN)rNrOrPrQr�r�r�r�r�r�r��ctypesrr�rrrrr��s


_r��__main__r;)&rQr�r'Zos.pathr�r�r`r
r/r*Ztest.supportrrrrZtest.support.os_helperrrrr�r^Z
unittest.mockr	r��ImportErrorr�r�r�r1r9r�rZTestCaserrRr�rN�mainrrrr�<module>sH�
�
(H	�
© 2025 GrazzMean