Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_venv.cpython-38.opt-2.pyc
U

>��g�Q�@s$ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
mZmZmZmZddlZddlZddlZzddlZWnek
r�dZYnXe�ejejkp�ejejkd�Zd
dd�ZGdd�dej�ZGdd	�d	e�Z eGd
d�de��Z!e"dk�r e�#�dS)�N)�captured_stdout�captured_stderr�
requires_zlib�can_symlink�EnvironmentVarGuard�rmtree�
import_module�*skip_if_broken_multiprocessing_synchronizez:cannot run venv.create from within a venv on this platformcCsBtj|tjtj|d�}|��\}}|jr:t�|j|||��||fS)N)�stdout�stderr�encoding)�
subprocess�Popen�PIPE�communicate�
returncode�CalledProcessError)�cmdr�p�out�err�r�-/opt/cppython/lib/python3.8/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
j}tj�
|�d
|_t
jdkr�tj�|�r�tj�|�s�d|_nd
|_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
Os>t��"}t��}|||�W5QRXW5QRX|��|��fSr;)rr�getvalue)r8�func�args�kwargs�output�errorrrr�run_with_captureJszBaseTest.run_with_capturecGstjj|jf|��Sr;)r'r(�joinr,)r8r@rrr�get_env_filePszBaseTest.get_env_filec	Gs(t|j|�d��}|��}W5QRX|S)N�r)�openrF�read)r8r@�f�resultrrr�get_text_file_contentsSszBaseTest.get_text_file_contentsN)	�__name__�
__module__�__qualname__ZmaxDiffr:r=rDrFrLrrrrr0s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�|��dSr;)rF�
assertTruer'r(�isdir)r8r@�fnrrrrR[s
zBasicTest.isdircCs$t|j�|�tj|j�|�|j�|�|j�|j|j�|�	d�}t
�d�dkohtj
dkohtjdk}|r�|�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�createrRr.r$r!rF�struct�calcsizer'r-r/r4rQr(�islink�assertFalser6rLr1�dirname�assertInr3�print�listdir)r8rZ
conditions�datar9r(rS�bdrrr�
test_defaults_s,

�
zBasicTest.test_defaultscCs�tj�|j�d}t|j�t��}|�|j|j�|�	|j�}|�
d�}|�|jd|�|�
d|�t|j�tjdd�}|�|j|j�|�	|j�}|�
d�}|�|jd�|�d|�dS)	N�rXz(%s) z	prompt = z	My prompt)�promptz(My prompt) zprompt = 'My prompt'
)r'r(r2r,rr\�
EnvBuilderrDr]Zensure_directoriesrL�assertEqualrjZassertNotInrc)r8Zenv_name�builder�contextrfrrr�test_prompt{s



zBasicTest.test_promptcCs�t|j�|�tj|j�tj�|j|j|j	�}|ddg}d|jfd|jfdt
jfdt
jffD]4\}}d||d<t
|�\}}|�|��|���q^dS)N�-c�prefix�exec_prefix�base_prefix�base_exec_prefixzimport sys; print(sys.%s)r#)rr,rDr\r]r'r(rEr.r3r/rsrtrrl�strip�encode)r8�envpyrrqZexpectedrrrrr�
test_prefixes�s

�zBasicTest.test_prefixesr&))r)rr)r�
site-packages)r )r$)r!r!r"Nr#ryc
CsZ|D]P}tjj|jf|��}t�|�tj�||�}t|d��}|�d�W5QRXqdS)N�wb�Still here?)r'r(rEr,�mkdirrH�write)r8�paths�filename�subdirs�drSrJrrr�create_contents�s
zBasicTest.create_contentsc
Cs�|�|jd�t�|j�|jD]T}tjj|jf|d��}|�tj�	|��t
|d��}|�|��d�W5QRXq tj
dd�}|�|j�|jD].}tjj|jf|d��}|�tj�	|��q�dS)N�foo)r��rbr{T��clear)r��ENV_SUBDIRSr\r]r,r'r(rErQr6rHrlrIrkra)r8r�rSrJrmrrr�test_overwrite_existing�s

z!BasicTest.test_overwrite_existingcCsZt�|�D]J}tj�||�}tj�|�s4tj�|�r@t�|�q
tj�|�r
t|�q
dSr;)	r'rer(rEr`�isfile�removerRr)r8r(rSrrr�clear_directory�szBasicTest.clear_directoryc
Csn|jdd�D]Z}tjj|jf|��}t|d��}|�d�W5QRX|�tt	ft
j|j�|�|j�qdS)N�rz�)
r�r'r(rEr,rHr}ZassertRaises�
ValueError�OSErrorr\r]r�)r8r~rSrJrrr�test_unoverwritable_fails�sz#BasicTest.test_unoverwritable_failscCs�dD]�}tj|d�}|�|j|j�|�|j�|�|j�|j|j�|�	|j|j
�}tj�
|�s�|�	|j�}td|�tdt�|��|�tj�
|�d|�qdS)N�FT)�upgraderYrZr[)r\rkrDr]r,rRr.r$r!rFr3r'r(r6rdrerQ)r8r�rmrSrgrrr�test_upgrade�szBasicTest.test_upgradecCsFdD]<\}}tjd|d�}|�|j�|�d�}|�d||�qdS)N))T�true)FZfalseT)r��system_site_packagesrXz"include-system-site-packages = %s
)r\rkr]r,rLrc)r8Zssp�srmrfrrr�test_isolation�s

zBasicTest.test_isolationzNeeds symlinkscCshdD]^}tjd|d�}|�|j�|�|j|j�}|r|jrP|�t	j
�|��q|�t	j
�|��qdS)Nr�T�r��symlinks)
r\rkr]r,rFr.r3r7rar'r(r`rQ)r8ZuslrmrSrrr�test_symlinking�szBasicTest.test_symlinkingcCsbt|j�|�tj|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)Nrp�!import sys; print(sys.executable))rr,rDr\r]r'r(rEr)r.r3rrlrurv�r8rwrrrrr�test_executables
��
zBasicTest.test_executablecCslt|j�tjddd�}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)NTr�rpr��rr,r\rkr]r'r(rEr)r.r3rrlrurv�r8rmrwrrrrr�test_executable_symlinks$s
��
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�&rpzprint(0)Zoem)r�0)rr,r'r(rEr)r\rkr]r.r3rrlru)r8r,rm�activaterwrrrrr�test_unicode_in_batch_file2s

�
z$BasicTest.test_unicode_in_batch_filecCsht�t|j�|�tj|j�tj�tj�	|j�|j
|j�}t|ddg�\}}|�
|��d���dS)Nrpzrfrom multiprocessing import Pool; pool = Pool(1); print(pool.apply_async("Python".lower).get(3)); pool.terminate()Zpython)r	rr,rDr\r]r'r(rEr)r.r3rrlrurvr�rrr�test_multiprocessingCs
��
zBasicTest.test_multiprocessingznot relevant on Windowsc	Cs�t�d�}|dkr|�d�t|j�tjdd�}|�|j�tj	�
|j|jd�}tj	�
|jd�}t|d��}|�
d|�d	��W5QRXt||g�\}}|�|d
���|�|d
���dS)N�bashzbash required for this testTr�r�ztest_strict.sh�wzset -euo pipefail
source z
deactivate
�)�shutil�whichZskipTestrr,r\rkr]r'r(rEr.rHr}rrlrv)r8r�rmr�Ztest_scriptrJrrrrr�%test_deactivate_with_strict_bash_optsXs


z/BasicTest.test_deactivate_with_strict_bash_optsrWzonly relevant on macOScCsft|j�t��}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�d���dS)Nrpz5import os; print("__PYVENV_LAUNCHER__" in os.environ)�Falser�r�rrr�test_macos_envks
��
zBasicTest.test_macos_env)rMrNrOrRrhro�requireVenvCreaterxr/r4r�r0r�r�r�r�r�r��unittest�
skipUnlessrr�r�r�r'r-r�r�ZskipIfr�r�rrrrrPXsB

�	







rPc@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)Nrpz1try:
 import pip
except ImportError:
 print("OK")�latin-1r�ZOK)r'r(rEr)r,r.r3r�decoderlrur�rrr�assert_pip_not_installedzs��


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_pipc	Cs@ttjd��}|�|��d�W5QRX|�tj�tj��dS)Nr�r�)rHr'�devnullrlrIrQr(r6)r8rJrrr�test_devnull�szEnsurePipTest.test_devnullcCs6t|j�t���}d|d<d|d<t����}||d<d}d}d}|fD]N\}}tj�||�}	t�|	�tj�|	|�}
t	|
d	��}|�
|�W5QRXqFz|jtj
|j|d
d�WnHtjk
r�}z(|jjdd
�}
d}|�|�||
��W5d}~XYnXW5QRXW5QRXtj�tj�|j�|j|j�}t|ddddddg�\}}|�d�}|�|d�|�d�}d�t���}|�|dt|��|�t�|j��d�}|�||�t��}t|dddddg�\}}W5QRX|�d�}tjdd|tj d�}|�|�!�d�|�d�}|�d|�|�d|�|�s2|�"�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	--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*�TemporaryDirectoryr'r(rEr|rHr}rDr\r]r
rrBr�Zfail�formatr)r.r3rrl�	ensurepip�version�len�fsencoderc�re�sub�	MULTILINE�rstripr�)r8r��envvarsZhome_dirZ
bad_configZwin_locationZposix_locationrbZfname�dirpathZfpathrJ�excZdetails�msgrwrrZexpected_versionr,rrr�do_test_with_pip�sr


�
8
�

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

Z
r��__main__)N)$r�r'Zos.pathr�r�r^r
r/r*Ztest.supportrrrrrrrr	�	threadingr�r\r��ImportErrorr�rqrsr1r9r�rZTestCaserrPr�rM�mainrrrr�<module>s>(

�
(!


F1le Man4ger