Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_venv.cpython-39.opt-2.pyc

a

��g�f�@s.ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZmZmZmZmZddlZddlZddlmZzddlZWney�dZYn0e�ejejkp�ejejkd�Zddd�ZGdd�dej �Z!Gd	d
�d
e!�Z"eGdd�de!��Z#e$d
k�r*e�%�dS)�N)�captured_stdout�captured_stderr�
requires_zlib�can_symlink�EnvironmentVarGuard�rmtree�
import_module�*skip_if_broken_multiprocessing_synchronize)�patchz: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�*/usr/local/lib/python3.9/test/test_venv.py�check_output&s�
�rc@sFeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�dd
�Zdd�Z	dS)�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�setUp5s"


�
�zBaseTest.setUpcCst|j�dS�N)rr-�r9rrr�tearDownHszBaseTest.tearDownc	Osjt��D}t��}||i|��Wd�n1s20YWd�n1sP0Y|��|��fSr<)rr�getvalue)r9�func�args�kwargs�output�errorrrr�run_with_captureKsJzBaseTest.run_with_capturecGstjj|jg|�R�Sr<)r(r)�joinr-)r9rArrr�get_env_fileQszBaseTest.get_env_filezutf-8�r
cGs@t|j|�d|d��}|��}Wd�n1s20Y|S)N�rrH)�openrG�read)r9r
rA�f�resultrrr�get_text_file_contentsTs&zBaseTest.get_text_file_contentscCs$|�|�s |�d|�d|���dS)NzString z does not end with )�endswith�fail)r9�string�tailrrr�assertEndsWithYs
zBaseTest.assertEndsWithN)
�__name__�
__module__�__qualname__ZmaxDiffr;r>rErGrNrSrrrrr1src	@s�eZdZdd�Zdd�Zdd�Zdd�Zed	d
��Ze	j
dkrDdZn4d
dddde	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+��Ze�ejd(kd)�d,d-��Ze�ejd(kd.�d/d0��Ze�ejd(kd.�d1d2��Zed3d4��Z e�ejd(kd5�d6d7��Z!e�e	j
d8kd9�d:d;��Z"dS)<�	BasicTestcGs |j|�}|�tj�|��dSr<)rG�
assertTruer(r)�isdir)r9rA�fnrrrrY`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-rE�venv�createrYr/r%r"rG�struct�calcsizer(r.r0r5rXr)�islink�assertFalser7rNr2�dirname�assertInr4�print�listdir)r9rZ
conditions�datar:r)rZ�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�r_z(%s) z	prompt = z	My prompt)�promptz(My prompt) zprompt = 'My prompt'
�.zprompt = '%s'
)r(r)r3r-rrc�
EnvBuilderrErd�ensure_directoriesrN�assertEqualrqZassertNotInrj�basename�getcwd)r9�env_name�builder�contextrm�cwdrrr�test_prompt�s.





zBasicTest.test_promptc	s�t��}tjdkrdnd}tj�tj�d}t�	���}tj�
tj�|||���tjdkrltj�
tj�������fdd�}|�
|�}td|��|�|�Wd�n1s�0YWd�n1s�0YdS)Nr'rr!rpc
s2tj�|d�|d<��|�ddddddg�dS)Nr�-m�pip�installz	--upgradeZ
setuptools)r(r)�normcaseru)r�Z
expect_exer9rr�pip_cmd_checker�s��z<BasicTest.test_upgrade_dependencies.<locals>.pip_cmd_checkerzvenv.subprocess.check_call)rcrsr0r5r(r)r3r:r+�TemporaryDirectoryr�rFr*rtr
Zupgrade_dependencies)r9ryZbin_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]4\}}d||d<t
|�\}}|�|��|���q^dS)N�-c�prefix�exec_prefix�base_prefix�base_exec_prefixzimport sys; print(sys.%s)r$)rr-rErcrdr(r)rFr/r4r0r�r�rru�strip�encode)r9�envpyrr�Zexpectedrrrrr�
test_prefixes�s

�zBasicTest.test_prefixesr'))r)r r)r�
site-packages)r!)r%)r"r"r#Nr$r�c	Csp|D]f}tjj|jg|�R�}t�|�tj�||�}t|d��}|�d�Wd�q1s`0YqdS)N�wb�Still here?)r(r)rFr-�mkdirrJ�write)r9�paths�filename�subdirs�drZrLrrr�create_contents�s
zBasicTest.create_contentsc	Cs�|�|jd�t�|j�|jD]j}tjj|jg|d�R�}|�tj�	|��t
|d�� }|�|��d�Wd�q 1s�0Yq tj
dd�}|�|j�|jD]0}tjj|jg|d�R�}|�tj�	|��q�dS)N�foo)r��rbr�T��clear)r��ENV_SUBDIRSrcrdr-r(r)rFrXr7rJrurKrsrh)r9r�rZrLryrrr�test_overwrite_existing�s
0
z!BasicTest.test_overwrite_existingcCsZt�|�D]J}tj�||�}tj�|�s4tj�|�r@t�|�q
tj�|�r
t|�q
dSr<)	r(rlr)rFrg�isfile�removerYr)r9r)rZrrr�clear_directory�szBasicTest.clear_directoryc	Cs�|jdd�D]p}tjj|jg|�R�}t|d��}|�d�Wd�n1sR0Y|�tt	ft
j|j�|�|j�qdS)N�r��)
r�r(r)rFr-rJr�ZassertRaises�
ValueError�OSErrorrcrdr�)r9r�rZrLrrr�test_unoverwritable_failss(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)�upgrader`rarb)rcrsrErdr-rYr/r%r"rGr4r(r)r7rkrlrX)r9r�ryrZrnrrr�test_upgradeszBasicTest.test_upgradecCsFdD]<\}}tjd|d�}|�|j�|�d�}|�d||�qdS)N))T�true)FZfalseT)r��system_site_packagesr_z"include-system-site-packages = %s
)rcrsrdr-rNrj)r9Zssp�sryrmrrr�test_isolation!s

zBasicTest.test_isolationzNeeds symlinkscCshdD]^}tjd|d�}|�|j�|�|j|j�}|r|jrP|�t	j
�|��q|�t	j
�|��qdS)Nr�T�r��symlinks)
rcrsrdr-rGr/r4r8rhr(r)rgrX)r9ZuslryrZrrr�test_symlinking+szBasicTest.test_symlinkingcCsbt|j�|�tj|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)Nr��!import sys; print(sys.executable))rr-rErcrdr(r)rFr*r/r4rrur�r��r9r�rrrrr�test_executableCs
��
zBasicTest.test_executablecCslt|j�tjddd�}|�|j�tj�tj�|j�|j	|j
�}t|ddg�\}}|�|�
�|���dS)NTr�r�r��rr-rcrsrdr(r)rFr*r/r4rrur�r��r9ryr�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�n1s�0Yt||g�\}}	|��}
|�|��|
dv�|�|
d|���dS)
N�bash�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
rrp�rr-�shutil�which�skipTestr(r)rFr*rcrsrdr/rJr��shlex�quoter�
splitlinesrXr�rS)r9r�rxr-ryr��test_scriptrLrr�linesrrr�test_special_chars_bash_s 



6z!BasicTest.test_special_chars_bashcCst|j�t�d�pt�d�}|dur0|�d�d}tj�tj�|j�|�}t	j
dd�}|�|�tj�||jd�}tj�|jd�}t
|d	��(}|�d
t�|��d��Wd�n1s�0Yt||g�\}}	|��}
|�|��|
dv�|�|
d
|���dS)NZtcsh�cshzcsh required for this testr�Tr�zactivate.cshztest_special_chars.cshr�r�r�rrpr�)r9r�rxr-ryr�r�rLrrr�rrr�test_special_chars_cshys 


6z BasicTest.test_special_chars_cshzonly relevant on Windowsc

Cs�t|j�d}tj�tj�|j�|�}tjdd�}|�|�tj�||j	d�}tj�|jd�}t
|d��2}|�d|�d|j�d	|j�d
��Wd�n1s�0Yt
|g�\}}|��}	|�|��|	dv�|�|	d|���dS)
Nz'&&^$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'])" & deactivaterrp)rr-r(r)rFr*rcrsrdr/rJr�r4rr�rXr�rS)
r9rxr-ryr�Z
test_batchrLrrr�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)NuϼўТλФЙTr�r��&r�zprint(0)ZoemrH�0)rr-r(r)rFr*rcrsrdr/r4rrur�)r9r-ryr�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)Nr�zrfrom multiprocessing import Pool; pool = Pool(1); print(pool.apply_async("Python".lower).get(3)); pool.terminate()Zpython)r	rr-rErcrdr(r)rFr*r/r4rrur�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�n1s�0Yt||g�\}}|�|d
���|�|d
���dS)Nr�r�Tr�r�ztest_strict.shr�zset -euo pipefail
source z
deactivate
�)r�r�r�rr-rcrsrdr(r)rFr/rJr�rrur�)r9r�ryr�r�rLrrrrr�%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)#rTrUrVrYror|r��requireVenvCreater�r0r5r�r1r�r�r�r�r�r��unittest�
skipUnlessrr�r�r�ZskipIfr(r.r�r�r�r�r�r�r�rrrrrW]sP

�	









rWc@sNeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Ze�	e
d�e�dd
���ZdS)�
EnsurePipTestcCsdtj�tj�|j�|j|j�}t|ddg�\}}|�d�}|�	|d�|�d�}|�	|�
�d�dS)Nr�z1try:
 import pip
except ImportError:
 print("OK")�latin-1r�ZOK)r(r)rFr*r-r/r4r�decoderur�r�rrr�assert_pip_not_installed�s��


z&EnsurePipTest.assert_pip_not_installedcCs&t|j�|�tj|j�|��dSr<�rr-rErcrdr�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�n1s20Y|�tj�tj��dS)Nr�r�)rJr(�devnullrurKrXr)r7)r9rLrrr�test_devnull	s.zEnsurePipTest.test_devnullcCs�t|j�t���0}d|d<d|d<t����}||d<d}d}d}|fD]b\}}tj�||�}	t�|	�tj�|	|�}
t	|
d	��}|�
|�Wd�qH1s�0YqHz|jtj
|j|d
d�WnLtj�y}z0|jjdd
�}
d}|�|�||
��WYd}~n
d}~00Wd�n1�s*0YWd�n1�sJ0Ytj�tj�|j�|j|j�}t|ddddddg�\}}|�d�}|�|d�|�d�}d�t���}|�|dt|��|�t�|j��d�}|�||�t��(}t|dddddg�\}}Wd�n1�s&0Y|�d�}tjdd|tj d�}|�|�!�d�|�d�}|�d|�|�d|�|�s�|�"�dS)N�eZPYTHONWARNINGS�1ZPIP_NO_INSTALL�HOMEz[global]
no-install=1)r~zpip.ini)z.pipzpip.confr�T)r�r��replace)�errorsz{}

**Subprocess Output**
{}z-Wzignore::DeprecationWarningz-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)rFr�rJr�rErcrdrrrCr�rP�formatr*r/r4rru�	ensurepip�version�len�fsencoderj�re�sub�	MULTILINE�rstripr�)r9r��envvarsZhome_dirZ
bad_configZwin_locationZposix_locationriZfname�dirpathZfpathrL�exc�details�msgr�rrZexpected_versionr-rrr�do_test_with_pipsf



*�
h
�


�*
�
zEnsurePipTest.do_test_with_pipzpip requires ctypescCs|�d�|�d�dS)NFT)r�r=rrr�
test_with_pipms
zEnsurePipTest.test_with_pipN)
rTrUrVr�r�r�r�r�r�r��ctypesrr�rrrrr��s

Z
r��__main__)N)&r�r(Zos.pathr�r�rerr0r+r�Ztest.supportrrrrrrrr	r�rcZ
unittest.mockr
r��ImportErrorr�r�r�r2r:r�rZTestCaserrWr�rT�mainrrrr�<module>sB(

�
,


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists