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-1.pyc
U

>��g�Q�@s(dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZmZmZmZmZddlZddlZddlZzddlZWnek
r�dZYnXe�ejejkp�ejejkd�Zddd�ZGdd�dej�Z Gd	d
�d
e �Z!eGdd�de ��Z"e#d
k�r$e�$�dS)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�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@s<eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�BaseTestzBase class for venv tests.i�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__�__doc__ZmaxDiffr:r=rDrFrLrrrrr0src	@s:eZdZdZdd�Zdd�Zdd�Zedd	��Ze	j
d
kr@dZn4dd
ddde	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.d/��Ze�e	j
d0kd1�d2d3��ZdS)4�	BasicTestzTest venv module functionality.cGs |j|�}|�tj�|��dSr;)rF�
assertTruer'r(�isdir)r8r@�fnrrrrS[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)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�createrSr.r$r!rF�struct�calcsizer'r-r/r4rRr(�islink�assertFalser6rLr1�dirname�assertInr3�print�listdir)r8rZ
conditions�datar9r(rT�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�rYz(%s) z	prompt = z	My prompt)�promptz(My prompt) zprompt = 'My prompt'
)r'r(r2r,rr]�
EnvBuilderrDr^Zensure_directoriesrL�assertEqualrkZassertNotInrd)r8Zenv_name�builder�contextrgrrr�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)	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/rtrurrm�strip�encode)r8�envpyrrrZexpectedrrrrr�
test_prefixes�s

�zBasicTest.test_prefixesr&))r)rr)r�
site-packages)r )r$)r!r!r"Nr#rzc
CsZ|D]P}tjj|jf|��}t�|�tj�||�}t|d��}|�d�W5QRXqdS)zn
        Create some files in the environment which are unrelated
        to the virtual environment.
        �wb�Still here?N)r'r(rEr,�mkdirrH�write)r8�paths�filename�subdirs�drTrJrrr�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)zE
        Test creating environment in an existing directory.
        �foo)r��rbr|T��clearN)r��ENV_SUBDIRSr]r^r,r'r(rErRr6rHrmrIrlrb)r8r�rTrJrnrrr�test_overwrite_existing�s

z!BasicTest.test_overwrite_existingcCsZt�|�D]J}tj�||�}tj�|�s4tj�|�r@t�|�q
tj�|�r
t|�q
dSr;)	r'rfr(rEra�isfile�removerSr)r8r(rTrrr�clear_directory�szBasicTest.clear_directoryc
Csn|jdd�D]Z}tjj|jf|��}t|d��}|�d�W5QRX|�tt	ft
j|j�|�|j�qdS)N�r{�)
r�r'r(rEr,rHr~ZassertRaises�
ValueError�OSErrorr]r^r�)r8rrTrJrrr�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)zC
        Test upgrading an existing environment directory.
        �FT)�upgraderZr[r\N)r]rlrDr^r,rSr.r$r!rFr3r'r(r6rerfrR)r8r�rnrTrhrrr�test_upgrade�szBasicTest.test_upgradecCsFdD]<\}}tjd|d�}|�|j�|�d�}|�d||�qdS)z:
        Test isolation from system site-packages
        ))T�true)FZfalseT)r��system_site_packagesrYz"include-system-site-packages = %s
N)r]rlr^r,rLrd)r8Zssp�srnrgrrr�test_isolation�s

zBasicTest.test_isolationzNeeds symlinkscCshdD]^}tjd|d�}|�|j�|�|j|j�}|r|jrP|�t	j
�|��q|�t	j
�|��qdS)z3
        Test symlinking works as expected
        r�T�r��symlinksN)
r]rlr^r,rFr.r3r7rbr'r(rarR)r8ZuslrnrTrrr�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.
        rq�!import sys; print(sys.executable)N)rr,rDr]r^r'r(rEr)r.r3rrmrvrw�r8rxrrrrr�test_executables
��
zBasicTest.test_executablecCslt|j�tjddd�}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)r�Tr�rqr�N�rr,r]rlr^r'r(rEr)r.r3rrmrvrw�r8rnrxrrrrr�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)z0
        Test handling of Unicode paths
        uϼўТλФЙTr�zactivate.bat�&rqzprint(0)Zoem)r�0N)rr,r'r(rEr)r]rlr^r.r3rrmrv)r8r,rn�activaterxrrrrr�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)zA
        Test that the multiprocessing is able to spawn.
        rqzrfrom multiprocessing import Pool; pool = Pool(1); print(pool.apply_async("Python".lower).get(3)); pool.terminate()ZpythonN)r	rr,rDr]r^r'r(rEr)r.r3rrmrvrwr�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]rlr^r'r(rEr.rHr~rrmrw)r8r�rnr�Ztest_scriptrJrrrrr�%test_deactivate_with_strict_bash_optsXs


z/BasicTest.test_deactivate_with_strict_bash_optsrXzonly relevant on macOScCsft|j�t��}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�d���dS)Nrqz5import os; print("__PYVENV_LAUNCHER__" in os.environ)�Falser�r�rrr�test_macos_envks
��
zBasicTest.test_macos_env) rMrNrOrPrSrirp�requireVenvCreateryr/r4r�r0r�r�r�r�r�r��unittest�
skipUnlessrr�r�r�r'r-r�r�ZskipIfr�r�rrrrrQXsD

�	







rQc@sPeZdZdZdd�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)Nrqz1try:
 import pip
except ImportError:
 print("OK")�latin-1r�ZOK)r'r(rEr)r,r.r3r�decodermrvr�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'�devnullrmrIrRr(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.r3rrm�	ensurepip�version�len�fsencoderd�re�sub�	MULTILINE�rstripr�)r8r��envvarsZhome_dirZ
bad_configZwin_locationZposix_locationrcZfname�dirpathZfpathrJ�excZdetails�msgrxrrZexpected_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)rMrNrOrPr�r�r�r�r�r�r��ctypesrr�rrrrr�ws

Z
r��__main__)N)%rPr�r'Zos.pathr�r�r_r
r/r*Ztest.supportrrrrrrrr	�	threadingr�r]r��ImportErrorr�rrrtr1r9r�rZTestCaserrQr�rM�mainrrrr�<module>s@(

�
(!


F1le Man4ger