403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.217.84
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python312/Lib/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python312/Lib/test/__pycache__/test_venv.cpython-312.opt-1.pyc
�

���g@���r�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZmZmZmZmZmZmZmZmZmZmZddlmZmZmZmZmZddl m!Z!ddl"Z"ddl#Z#ddl$m%Z%m&Z&	ddl'Z'e"jRe
jTe
jVk(xse
jXe
jZk7d�Z.esere"j^d��e�dd	��Z0Gd
�de"jbe!�Z2Gd�d
e2�Z3e.Gd�de2��Z4e5dk(re"jl�yy#e($rdZ'Y��wxYw)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�*skip_if_broken_multiprocessing_synchronize�verbose�requires_subprocess�
is_emscripten�is_wasi�requires_venv_with_pip�
TEST_HOME_DIR�requires_resource�copy_python_src_ignore)�can_symlink�EnvironmentVarGuard�rmtree�TESTFN�FakePath)�ExtraAssertions)�patch�Mockz:cannot run venv.create from within a venv on this platformz)venv is not available on Emscripten/WASI.c�<�tj|tjtj|��}|j�\}}|jrEt
r|rt
|jdd��tj|j|||��||fS)N)�stdout�stderr�encoding�utf-8�backslashreplace)	�
subprocess�Popen�PIPE�communicate�
returncoder�print�decode�CalledProcessError)�cmdr�p�out�errs     �#C:\Python312\\Lib\test\test_venv.py�check_outputr)0s�������������	�A��}�}��H�C���|�|��s��#�*�*�W�&8�9�:��+�+�
�L�L�#�s�C�)�	)���8�O�c�8�eZdZdZdZd�Zd�Zd�Zd�Zdd�d	�Z	y
)�BaseTestzBase class for venv tests.i�c�F�tjjtj��|_tjdk(rd|_d|_d|_	n+d|_ddtjddzf|_d	|_	tj}tjj|�d
|_tjdk(rFtjj!|�r'tjj#|�sd|_yd
|_y)N�nt�Scripts��Lib�Include�bin�lib�python%d.%d��include����win32TF)�os�path�realpath�tempfile�mkdtemp�env_dir�name�bindirr4r7�sys�version_info�_base_executable�split�exe�platform�lexists�exists�cannot_link_exe)�self�
executables  r(�setUpzBaseTest.setUpBs����w�w�'�'��(8�(8�(:�;���
�7�7�d�?�#�D�K��D�H�$�D�L��D�K��}�s�/?�/?���/C�C�D�D�H�$�D�L��)�)�
��7�7�=�=��,�R�0����L�L�G�#������
�+��G�G�N�N�:�.�#'�D� �#(�D� r*c�.�t|j�y�N)rr?�rKs r(�tearDownzBaseTest.tearDownUs���t�|�|�r*c���t�5}t�5}||i|��ddd�ddd�j�j�fS#1swY�1xYw#1swY�5xYwrO)rr�getvalue)rK�func�args�kwargs�output�errors      r(�run_with_capturezBaseTest.run_with_captureXsV��
�
�&� �"�e��d�%�f�%�#����� �%�.�.�"2�2�2�#�"���
�s!�A�	A�A�A	�A�A$c�V�tjj|jg|���SrO)r:r;�joinr?)rKrUs  r(�get_env_filezBaseTest.get_env_file^s���w�w�|�|�D�L�L�0�4�0�0r*r�rc��t|j|�d|��5}|j�}ddd�|S#1swYSxYw)N�rr])�openr\�read)rKrrU�f�results     r(�get_text_file_contentszBaseTest.get_text_file_contentsas@��
�#�$�#�#�T�*�C�(�
C�q��V�V�X�F�D��
�D��
�s	�7�AN)
�__name__�
__module__�__qualname__�__doc__�maxDiffrMrQrYr\rd�r*r(r,r,>s(��$��G�)�&�3�1�6=�r*r,c	��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
ed	��Zed
��Z
eeje�d�d���Zej&d
k(rdZn,dddddej*ddzfddej*ddzdffZd�Zd�Zd�Zd�Zd�Zd�Zeje�d�d��Zed��Zeje�d�d��Zej>e jBd k(d!�d"��Z"ej>e jBd k(d!�d#��Z#eje jBd k(d$�d%��Z$eje jBd k(d$�d&��Z%ed'��Z&ed(��Z'ej>e jBd k(d)�d*��Z(ejej&d+k(d,�d-��Z)d.�Z*ej>e jBd k(d)�ed/���Z+d0�Z,d1�Z-y)2�	BasicTestzTest venv module functionality.c�~�|j|�}|jtjj	|��yrO)r\�
assertTruer:r;�isdir)rKrU�fns   r(rozBasicTest.isdiris-��
�T�
�
��
%��������
�
�b�)�*r*c��t|j�|jtj|j�|j�y)zQ
        Test the create function with default arguments and a str path.
        N)rr?rY�venv�create�_check_output_of_default_createrPs r(�test_defaults_with_str_pathz%BasicTest.test_defaults_with_str_pathms4��	�t�|�|�����d�k�k�4�<�<�8��,�,�.r*c��t|j�|jtjt|j��|j
�y)zW
        Test the create function with default arguments and a path-like path.
        N)rr?rYrrrsrrtrPs r(�test_defaults_with_pathlikez%BasicTest.test_defaults_with_pathlikeus9��	�t�|�|�����d�k�k�8�D�L�L�+A�B��,�,�.r*c�J�|j|j�|j|j�|j|j�|j	d�}tjd�dk(xr(tjdk(xrtjdk7}|r/|jtjj|��n.|jtjj|��|j!d�}tj"}tjj%|�}|j'd|z|�|j'dtjj)tj*�z|�tjd	k(rd
nd}dtj*�d
|�d|j,��}|j'||�|j	|j|j.�}tjj|�sJ|j	|j�}	t1d|	z�t1dtj2|	�z�|jtjj|�d|z�y)N�lib64�P��posix�darwin�
pyvenv.cfgz	home = %szexecutable = %sr.�z	 --copiesz
command = z -m venvz --without-pip �Contents of %r:�    %r�File %r should exist.)rorAr7r4r\�struct�calcsizer:r@rBrGrnr;�islink�assertFalserIrdrD�dirname�assertInr<rLr?rFr!�listdir)
rKr%�
conditions�datarLr;�copiesr$rp�bds
          r(rtz)BasicTest._check_output_of_default_create}s����
�
�4�;�;���
�
�4�<�<� ���
�
�D�H�H�����g�&�����s�+�q�0�1�r�w�w�'�7I�1��|�|�x�/�	���O�O�B�G�G�N�N�1�-�.����R�W�W�^�^�A�.�/��*�*�<�8���)�)�
��w�w���z�*���
�
�k�D�(�$�/��
�
�'��g�g�&�&�s�~�~�6�7�8<�	>��w�w��}��+���3�>�>�*�(�6�(�/�$�,�,��X���
�
�c�4� �
�
�
�t�{�{�D�H�H�
5���w�w�~�~�b�!��"�"�4�;�;�/�B��#�b�(�)��(�R�Z�Z��^�+�,���������r�*�,C�b�,H�Ir*c��gd�}|D]�\}}t|j�|stj�}ntjd
i||dvrdndi��}t	�|_t	�|_|j|j|j�|jd�}|sdD]}|j|d|������tjdk(r|d	k(r��|j|d|�����y)N))NN)�symlinksz--copies)�with_pip�
--without-pip)�system_site_packages�--system-site-packages)�clear�--clear)�upgrade�	--upgrade)�upgrade_deps�--upgrade-deps)�prompt�--prompt)r�r�FTr~)r�r�r�r�r�z
command = .* r.r�rj)rr?rr�
EnvBuilderr�upgrade_dependencies�
_setup_piprYrsrd�assertNotRegexr:r@�assertRegex)rK�attrs�attr�opt�br�s      r(�test_config_file_command_keyz&BasicTest.test_config_file_command_key�s���	
���I�D�#��4�<�<� ���O�O�%���O�O�S��d�.F�&F�U�D�Q�S��%)�V�A�"��6�A�L��!�!�!�(�(�D�L�L�9��.�.�|�<�D��6�C��'�'���s�e�.D�E�6����$��4��#3��� � ��-��u�'=�>�%r*c���tjj|j�d}t	|j�tj�}|j|j|j�|j|j�}|jd�}|j|jd|z�|jd|�t	|j�tjd��}|j|j|j�|j|j�}|jd�}|j|jd�|jd|�t	|j�tjd	��}tjjtj ��}|j|j|j�|j|j�}|jd�}|j|jd|z�|jd
|z|�y)N�r~z(%s) z	prompt = z	My prompt)r�z(My prompt) zprompt = 'My prompt'
�.zprompt = '%s'
)r:r;rEr?rrrr�rYrs�ensure_directoriesrd�assertEqualr��assertNotInr��basename�getcwd)rK�env_name�builder�contextr��cwds      r(�test_promptzBasicTest.test_prompt�s����7�7�=�=����.�q�1���t�|�|���/�/�#�����g�n�n�d�l�l�;��,�,�T�\�\�:���*�*�<�8���������8�);�<�����d�+��t�|�|���/�/��5�����g�n�n�d�l�l�;��,�,�T�\�\�:���*�*�<�8���������8��
�
�.��5��t�|�|���/�/��-���g�g���r�y�y�{�+�����g�n�n�d�l�l�;��,�,�T�\�\�:���*�*�<�8���������3��7��
�
�'�#�-�t�4r*c����tj�}tjdk(rdnd}tj
j
tj�d}tj�5}tj
jtj
j|||���tjdk(r<tj
jtj
j������fd�}|j|�}td|�5|j|�ddd�ddd�y#1swY�xYw#1swYyxYw)Nr9r/r3r�c	���tjj|d�|d<�j|�dddddg�y)Nr�-m�pip�installr�)r:r;�normcaser�)r$rV�
expect_exerKs  ��r(�pip_cmd_checkerz<BasicTest.test_upgrade_dependencies.<locals>.pip_cmd_checker�sG������)�)�#�a�&�1��A��� � ��"���!�#��
�
r*zvenv.subprocess.check_output)rrr�rBrGr:r;rErLr=�TemporaryDirectoryr�r[r<r�rr�)rKr��bin_path�
python_exe�fake_env_dirr��fake_contextr�s`      @r(�test_upgrade_dependenciesz#BasicTest.test_upgrade_dependencies�s�����/�/�#�� #���� 7�9�U���W�W�]�]�3�>�>�2�1�5�
�
�
(�
(�
*�l����)�)������\�8�Z�@��J��|�|�w�&��W�W�-�-�b�g�g�.>�.>�z�.J�K�
�
�#�5�5�l�C�L��5��G��,�,�\�:�H�-+�
*�,H�G��-+�
*�s%�2B1E�#E�5E�E	�E�Ec�l�t|j�|jtj|j�t
jj|j|j|j�}|ddg}d|jfd|jfdtjfdtjffD]p\}}d|z|d<t|�\}}|jtj |j#�j%��tj |�|��ry)	z>
        Test that the prefix values are as expected.
        �-cN�prefix�exec_prefix�base_prefix�base_exec_prefixzimport sys; print(sys.%s)r6)rr?rYrrrsr:r;r[rArFrBr�r�r)r��pathlib�Path�stripr")rK�envpyr$r��expectedr&r's       r(�
test_prefixeszBasicTest.test_prefixes�s���	�t�|�|�����d�k�k�4�<�<�8������T�\�\�4�;�;����A���d�D�!��
�t�|�|�$�
�D�L�L�)�
�C�O�O�,�
��!5�!5�6�	!8��F�H�
1�6�9�C��F�#�C�(�H�C�����W�\�\�#�)�)�+�*<�*<�*>�?�$�\�\�(�3�V�
=�!8r*c��t|j�|jtj|jd��t
jj|j|j|j�}|ddg}dddttj��fdtj�fd	tj�ffD]d\}}|j|�5d
|z|d<t!|�\}}|j#|j%�|j'�|�ddd��fy#1swY�qxYw)�R
        Test that the sysconfig functions work in a virtual environment.
        F�r�r�N�zget_preferred_scheme("prefix")rr�zget_default_scheme()rr�is_python_build()�get_makefile_filename()�get_config_h_filename()�%import sysconfig; print(sysconfig.%s)r6�rr?rYrrrsr:r;r[rArF�str�	sysconfig�is_python_build�get_makefile_filename�get_config_h_filename�subTestr)r�r��encode�rKr�r$�callr�r&r's       r(�test_sysconfigzBasicTest.test_sysconfigs��
	�t�|�|�����d�k�k�4�<�<�%��H������T�\�\�4�;�;����A���d�D�!��
7�,�
 �#�i�&?�&?�&A�"B�C�
&�	�(G�(G�(I�J�
&�	�(G�(G�(I�J�L�N�D�(����d�#�@�4�G��A��'��,���S�� � �����h�o�o�.?��E�$�#�L�$�#��
�)AD:�:E	zNeeds symlinksc��t|j�|jtj|jd��t
jj|j|j|j�}|ddg}dddttj��fdtj�fd	tj�ffD]d\}}|j|�5d
|z|d<t!|�\}}|j#|j%�|j'�|�ddd��fy#1swY�qxYw)r�Tr�r�Nr�r�r�r�r�r�r6r�r�s       r(�test_sysconfig_symlinksz!BasicTest.test_sysconfig_symlinkss��	�t�|�|�����d�k�k�4�<�<�$��G������T�\�\�4�;�;����A���d�D�!��
7�,�
 �#�i�&?�&?�&A�"B�C�
&�	�(G�(G�(I�J�
&�	�(G�(G�(I�J�L�N�D�(����d�#�@�4�G��A��'��,���S�� � �����h�o�o�.?��E�$�#�L�$�#�r�r9))r/)r2r0)r1�
site-packages)r3)r7)r4r4r5Nr6r�c�4�|D]�}tjj|jg|���}tj|�tjj||�}t|d�5}|j
d�ddd���y#1swY��xYw)zn
        Create some files in the environment which are unrelated
        to the virtual environment.
        �wb�Still here?N)r:r;r[r?�mkdirr`�write)rK�paths�filename�subdirs�drprbs       r(�create_contentszBasicTest.create_contentsBsn��
�G������T�\�\�4�G�4�A��H�H�Q�K������a��*�B��b�$��1�����'� ��	� ��s�1B�B	c��|j|jd�tj|j�|jD]�}tjj|jg|dz���}|jt
jj|��t|d�5}|j|j�d�ddd���tjd��}|j|j�|jD]]}tjj|jg|dz���}|jt
jj|���_y#1swY��=xYw)zE
        Test creating environment in an existing directory.
        �foo)r��rbr�NT�r�)r��ENV_SUBDIRSrrrsr?r:r;r[rnrIr`r�rar�r�)rKr�rprbr�s     r(�test_overwrite_existingz!BasicTest.test_overwrite_existingNs��	
���T�-�-�u�5����D�L�L�!��'�'�G������d�l�l�B�g��.@�B�B��O�O�B�G�G�N�N�2�.�/��b�$��1�� � �����>�:� ��(��/�/��-�����t�|�|�$��'�'�G������d�l�l�B�g��.@�B�B����R�W�W�^�^�B�/�0�(� ��s�2!E;�;F	c�v�tj|�D]�}tjj||�}tjj	|�stjj|�rtj|��wtjj|�s��t|���yrO)	r:r�r;r[r��isfile�removeror)rKr;rps   r(�clear_directoryzBasicTest.clear_directory`sj���*�*�T�"�B������d�B�'�B��w�w�~�~�b�!�R�W�W�^�^�B�%7��	�	�"�
������r�"��r�
�#r*c��|jddD]�}tjj|jg|���}t|d�5}|j
d�ddd�|jttftj|j�|j|j���y#1swY�\xYw)N�r�r*)
r�r:r;r[r?r`r��assertRaises�
ValueError�OSErrorrrrsr�)rKr�rprbs    r(�test_unoverwritable_failsz#BasicTest.test_unoverwritable_failshs����%�%�b�q�)�E������d�l�l�3�U�3�B��b�$��1������ ����z�7�3�T�[�[�$�,�,�O�� � ����.�*���s�	B6�6B?	c��dD�]O}tj|��}|j|j|j�|j|j�|j|j�|j
|j�|j|j|j�}tjj|�sJ|j|j�}td|z�tdtj|�z�|j!tjj|�d|z���Ry)zC
        Test upgrading an existing environment directory.
        �FT)r�r�r�r�N)rrr�rYrsr?rorAr7r4r\rFr:r;rIr!r�rn)rKr�r�rpr�s     r(�test_upgradezBasicTest.test_upgradeqs���%�G��o�o�g�6�G��!�!�'�.�.�$�,�,�?��J�J�t�{�{�#��J�J�t�|�|�$��D�J�J����!��"�"�4�;�;����9�B��7�7�>�>�"�%��&�&�t�{�{�3���'�"�,�-��h����B��/�0��O�O�B�G�G�N�N�2�.�0G�"�0L�M�%r*c���dD]]\}}tjd|��}|j|j�|j	d�}|jd|z|��_y)z:
        Test isolation from system site-packages
        ))T�true)F�falseT)r�r�r~z"include-system-site-packages = %s
N)rrr�rsr?rdr�)rK�ssp�sr�r�s     r(�test_isolationzBasicTest.test_isolation�sV��9�F�C���o�o�D�s�K�G��N�N�4�<�<�(��.�.�|�<�D��M�M�?�!�C�T�J�	9r*c��dD]�}tjd|��}|j|j�|j	|j
|j�}|s�^|jr/|jtjj|����|jtjj|����y)z3
        Test symlinking works as expected
        rT�r�r�N)
rrr�rsr?r\rArFrJr�r:r;r�rn)rK�uslr�rps    r(�test_symlinkingzBasicTest.test_symlinking�s���
!�C��o�o�D�3�?�G��N�N�4�<�<�(��"�"�4�;�;����9�B���'�'��$�$�R�W�W�^�^�B�%7�8��O�O�B�G�G�N�N�2�$6�7�!r*c��t|j�|jtj|j�t
jjt
jj|j�|j|j�}t|ddg�\}}|j|j�|j��y)�D
        Test that the sys.executable value is as expected.
        r��!import sys; print(sys.executable)N)rr?rYrrrsr:r;r[r<rArFr)r�r�r��rKr�r&r's    r(�test_executablezBasicTest.test_executable�s���
	�t�|�|�����d�k�k�4�<�<�8������R�W�W�-�-�d�l�l�;�!�[�[�$�(�(�4�����/�!1�2���S��������e�l�l�n�5r*c���t|j�tjdd��}|j	|j�t
jjt
jj|j�|j|j�}t|ddg�\}}|j|j�|j��y)r
Tr	r�rN�rr?rrr�rsr:r;r[r<rArFr)r�r�r��rKr�r�r&r's     r(�test_executable_symlinksz"BasicTest.test_executable_symlinks�s���
	�t�|�|���/�/��t�<�����t�|�|�$������R�W�W�-�-�d�l�l�;�!�[�[�$�(�(�4�����/�!1�2���S��������e�l�l�n�5r*r.z&contains invalid characters on Windowsc�h�t|j�tjd�}|�|j	d�d}t
jjt
jj|j�|�}tjd��}|j|�t
jj||jd�}t
jj|jd�}t|d	�5}|jd
tj |��d��ddd�t#||g�\}}	|j%�}
|j'|j)�|
dv�|j+|
d
|j)��y#1swY�qxYw)zK
        Test that the template strings are quoted properly (bash)
        �bashN�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
rr��rr?�shutil�which�skipTestr:r;r[r<rrr�rsrAr`r��shlex�quoter)�
splitlinesrnr��assertEndsWith)rKrr�r?r�r�test_scriptrbr&r'�liness           r(�test_special_chars_bashz!BasicTest.test_special_chars_bash�sA��
	�t�|�|���|�|�F�#���<��M�M�7�8�!���'�'�,�,�r�w�w�/�/����=�x�H���/�/��-�����w���7�7�<�<�����j�A���g�g�l�l�4�<�<�1H�I��
�+�s�
#�q�
�G�G�g�e�k�k�(�3�4�5#�#�
$�$�
 ��{� 3�4���S���� ��������)�U�1�X�5�6����E�!�H�h�o�o�&7�8�$�
#�s�)F(�(F1c��t|j�tjd�xstjd�}|�|j	d�d}t
jjt
jj|j�|�}tjd��}|j|�t
jj||jd�}t
jj|jd	�}t|d
�5}|jdtj |��d��ddd�t#||g�\}}	|j%�}
|j'|j)�|
d
v�|j+|
d|j)��y#1swY�qxYw)zJ
        Test that the template strings are quoted properly (csh)
        �tcsh�cshNzcsh required for this testrTr�zactivate.cshztest_special_chars.cshrrrrr�r)rKr*r�r?r�rr%rbr&r'r&s           r(�test_special_chars_cshz BasicTest.test_special_chars_csh�sO��
	�t�|�|���l�l�6�"�9�f�l�l�5�&9���;��M�M�6�7�!���'�'�,�,�r�w�w�/�/����=�x�H���/�/��-�����w���7�7�<�<�����n�E���g�g�l�l�4�<�<�1I�J��
�+�s�
#�q�
�G�G�g�e�k�k�(�3�4�5#�#�
$�$�
 ��k� 2�3���S���� ��������)�U�1�X�5�6����E�!�H�h�o�o�&7�8�$�
#�s�&)F?�?Gzonly relevant on Windowsc
�$�t|j�d}tjj	tjj|j�|�}t
jd��}|j|�tjj	||jd�}tjj	|jd�}t|d�5}|jd|�d|j�d	|j�d
��ddd�t|g�\}}|j�}	|j|j!�|	dv�|j#|	d
|j!��y#1swY�pxYw)zO
        Test that the template strings are quoted properly on Windows
        z'&&^$eTr��activate.batztest_special_chars.batrz@echo off
"z" & z* -c "import sys; print(sys.executable)" & z> -c "import os; print(os.environ['VIRTUAL_ENV'])" & deactivateNrr�)rr?r:r;r[r<rrr�rsrAr`r�rFr)r#rnr�r$)
rKr�r?r�r�
test_batchrbr&r'r&s
          r(�test_special_chars_windowsz$BasicTest.test_special_chars_windows�s/��
	�t�|�|�����'�'�,�,�r�w�w�/�/����=�x�H���/�/��-�����w���7�7�<�<�����n�E���W�W�\�\�$�,�,�0H�I�
�
�*�c�
"�a�
�G�G�� �z���x�x�j� J��x�x�j�!!�!�
"�#� ���-���S���� ��������)�U�1�X�5�6����E�!�H�h�o�o�&7�8�#�
"�s�'0F�Fc�H�t|j�tjj	tjj|j�d�}t
jd��}|j|�tjj	||jd�}tjj	||j|j�}t|d|jddgd�	�\}}|j|j�d
�y)z0
        Test handling of Unicode paths
        uϼўТλФЙTr�r-�&r�zprint(0)�oemr]�0N)rr?r:r;r[r<rrr�rsrArFr)r�r�)rKr?r�rr�r&r's       r(�test_unicode_in_batch_filez$BasicTest.test_unicode_in_batch_files���
	�t�|�|���'�'�,�,�r�w�w�/�/����=�~�N���/�/��-�����w���7�7�<�<�����n�E�������W�d�k�k�4�8�8�<���
�s�D�H�H�d�J�7��
���S�	
�������c�*r*c���t�t|j�|jtj
|j�tjjtjj|j�|j|j�}t|ddg�\}}|j|j�dj��y)zA
        Test that the multiprocessing is able to spawn.
        r�zrfrom multiprocessing import Pool; pool = Pool(1); print(pool.apply_async("Python".lower).get(3)); pool.terminate()�pythonN)rrr?rYrrrsr:r;r[r<rArFr)r�r�r�rs    r(�test_multiprocessingzBasicTest.test_multiprocessing s���	3�4��t�|�|�����d�k�k�4�<�<�8������R�W�W�-�-�d�l�l�;�!�[�[�$�(�(�4�����
�! �!���S�
	
�������h�o�o�&7�8r*c���t�t|j�|jtj
|j�tjjtjj|j�|j|j�}tjjtd�}tj|d|g�y)zG
        Test that the multiprocessing is able to spawn itself
        z_test_venv_multiprocessing.py�-IN)rrr?rYrrrsr:r;r[r<rArFrr�
check_call)rKr��scripts   r(�test_multiprocessing_recursionz(BasicTest.test_multiprocessing_recursion5s���
	3�4��t�|�|�����d�k�k�4�<�<�8������R�W�W�-�-�d�l�l�;�!�[�[�$�(�(�4�������m�-L�M�����u�d�F�3�4r*znot relevant on Windowsc��tjd�}|�|jd�t|j�tjd��}|j|j�tjj|j|jd�}tjj|jd�}t|d�5}|jd|�d	��ddd�t||g�\}}|j|d
j!��|j|d
j!��y#1swY�ZxYw)NrrTr�rztest_strict.shrzset -euo pipefail
source z
deactivate
r)rrr rr?rrr�rsr:r;r[rAr`r�r)r�r�)rKrr�rr%rbr&r's        r(�%test_deactivate_with_strict_bash_optsz/BasicTest.test_deactivate_with_strict_bash_optsCs����|�|�F�#���<��M�M�7�8��t�|�|���/�/��-�����t�|�|�$��7�7�<�<����d�k�k�:�F���g�g�l�l�4�<�<�1A�B��
�+�s�
#�q�
�G�G��&�Z�(#�#�
$�$� ��{� 3�4���S�����b�i�i�k�*�����b�i�i�k�*�
$�
#�s�E	�	Er}zonly relevant on macOSc���t|j�tj�}|j	|j�t
jjt
jj|j�|j|j�}t|ddg�\}}|j|j�dj��y)Nr�z5import os; print("__PYVENV_LAUNCHER__" in os.environ)�Falserrs     r(�test_macos_envzBasicTest.test_macos_envVs����t�|�|���/�/�#�����t�|�|�$������R�W�W�-�-�d�l�l�;�!�[�[�$�(�(�4�����C�!E�F���S��������g�n�n�&6�7r*c��t|j�|jtjz}|j	t
tj|�|j	t
tjt|��y)zn
        Test that venv creation fails when the target directory contains
        the path separator.
        N)	rr?r:�pathsepr�r�rrrsr)rK�bad_itempaths  r(�test_pathsep_errorzBasicTest.test_pathsep_errorbsS��
	�t�|�|���|�|�b�j�j�0�����*�d�k�k�<�@����*�d�k�k�8�L�3I�Jr*c	�	�t|j�tj}tj
j
tj��}|jt|�tj
j||j�}t	j|�tjtj|�tj
j|||j d�}t	j"|�tj
j|d�}dtj$ddz}tj
j|||�}g}tj
D�]�}	|	j'd�rUtj
j)|	�s�5tj*|	tj
j||���jtj
j)tj
j|	d��r�t	j,|	�}
t/|	|
�}|
D]�}||vr�|dk(r�tj
j|	|�}
tj
j)|
�rtj0|
|��dtj
j3|
�s��tj4|
tj
j||�t.�������|j7|	����tj
j||j|j8�d	d
d|jg}tj:j|�}t=j>d�}|rt=j@�rJtj
jCtj
jEtj��}tjFd
k(rd}nd}d|||i}tjHjKd�x}r||d<tMjN||��tj
j|j|j|j8�}|dddg}tQ|�\}}|jS|jU�|v�y)zr
        Test that when create venv from non-installed python, the zip path
        value is as expected.
        r�zos.pyzpython%d%d.zipNr6z.zipr�)�ignorer�rrr��LIBDIRr}�DYLD_LIBRARY_PATH�LD_LIBRARY_PATH�
PYTHONPATH�ASAN_OPTIONS)�envz-Sr�zimport sys; print(sys.path))+rr?rB�
platlibdirr:r;r<r=r>�
addCleanupr[rAr�r�copy2rLr4�makedirsrC�endswithr��copyfiler�r
�copyro�copytree�appendrFrCr��get_config_varr��abspathr�rG�environ�getrr:r)rnr�)rKrN�non_installed_dirrA�libdir�landmark�
stdlib_zip�zip_landmark�'additional_pythonpath_for_non_installed�eachpath�names�
ignored_namesr@rpr$�
pythonpath�ld_library_path�ld_library_path_env�	child_env�asan_optionsr�r&r's                       r(�%test_zippath_from_non_installed_posixz/BasicTest.test_zippath_from_non_installed_posixlsd��	�t�|�|���^�^�
��G�G�,�,�X�-=�-=�-?�@������ 1�2������/����=��
��������S�^�^�V�,������/��T�X�X�a�[�I��
���F���7�7�<�<���0��%��(8�(8��!�(<�<�
��w�w�|�|�$5�$.�$.�0��35�/����H�� � ��(��7�7�>�>�(�+��O�O� ������%6�
�C�E�����������X�w� ?�@��
�
�8�,�� 6�x�� G�
�!�D��}�,� ���.� ������h��5�B��w�w�~�~�b�)����B��/������r�*�����B�G�G�L�L���,F�/E�G�"�8�>�>���+!�.�w�w�|�|�-�t�{�{�D�H�H�E�����|�|�	���Z�Z�_�_�3�5�
�
$�2�2�8�<���)�";�";�"=� �g�g�o�o�b�g�g�o�o�c�n�n�.M�N�O��<�<�8�#�"5��"3���j�#�_�
�	��:�:�>�>�.�9�9�<�9�(4�I�n�%����c�y�1������T�\�\�4�;�;����A���d�D�"?�@����$���S�����+�+�-��4�5r*c�j�tj|j�}t|�|j^\}}||zdz}tj|�t|d�5}t|d�D]+\}}d|��}|j|jd�|��-	ddd�y#1swYyxYw)z�
        Test that the `activate` shell script contains no CR LF.
        This is relevant for Cygwin, as the Windows build might have
        converted line endings accidentally.
        rr�r�zCR LF found in line s
N)r�r�r?rr�rrrsr`�	enumerater�rR)	rK�venv_dir�scripts_dir�_�script_pathr;�i�line�
error_messages	         r(�.test_activate_shell_script_has_no_dos_newlinesz8BasicTest.test_activate_shell_script_has_no_dos_newlines�s����<�<����-���x��"�.�.���+����,�z�9�����H��
�+�t�
$��$�V�Q�/���4�"6�q�c� :�
�� � ����w�!7��G�0�%�
$�
$�s�$;B)�)B2c��tjj}tjdk(r~dt
t
fdtj�tj�fg}ddl}tjd�}|rcg|�d||f�d|j|�|j|�f�}n6dt
t
fdtj�tj�fg}|D]X\}}}|j|�d|���5|r|j|||��n|j|||��ddd��Zy#1swY�exYw)Nr9Tr�ProgramFilesF�-)rrr��
_same_pathrBrGr�lower�upper�_winapir:�getenv�GetShortPathName�GetLongPathNamer�rnr�)rK�	same_path�testsrz�	progfilesr_�path1�path2s        r(�test_venv_same_pathzBasicTest.test_venv_same_path�s.���O�O�.�.�	��<�<�7�"��v�v�&��v�|�|�~�v�|�|�~�6��E�
��	�	�.�1�I������9�i�0���7�3�3�I�>��@W�@W�Xa�@b�c����v�v�&����������7��E� %�O�A�u�e������q���0�1���O�O�I�e�U�$;�<��$�$�Y�u�e�%<�=�	2�1� %�1�1�s�4E�E		).rerfrgrhrorurwrtr�r�r��requireVenvCreater�r��unittest�
skipUnlessrr�rBrGr�rCr�r�r�r�rrrrr�skipIfr:r@r'r+r/r4r7r<r>rArErirsr�rjr*r(rlrlfs���)�+�/�/�J�8?�>5�8;�:�=��=�&�F��F�*��X�����(8�9�F�:��F�*�|�|�w��
��
���
�M�C�$4�$4�R�a�$8�8�9�
�M�C�$4�$4�R�a�$8�8�/�J�
��
(�1�$�/�N�*K��X�����(8�9�8�:�8�.�
6��
6��X�����(8�9�6�:�6��X�_�_�R�W�W��_�&N�O�9�P�9�2�X�_�_�R�W�W��_�&N�O�9�P�9�2�X������D��*D�E�9�F�9�,�X������D��*D�E�+�F�+� �9��9�(�5��5��X�_�_�R�W�W��_�&?�@�+�A�+�$�X�������1�3K�L�	8�M�	8�K��X�_�_�R�W�W��_�&?�@��Q6��A�Q6�fH� >r*rlc��eZdZdZd�Zd�Zd�Zd�Zd�Ze	jd��Ze�e
d�d	���Zy
)�
EnsurePipTestz%Test venv module installation of pip.c��tjjtjj|j�|j
|j�}t|ddg�\}}|jd�}|j|d�|jd�}|j|j�d�y)Nr�z1try:
 import pip
except ImportError:
 print("OK")�latin-1r�OK)r:r;r[r<r?rArFr)r"r�r�rs    r(�assert_pip_not_installedz&EnsurePipTest.assert_pip_not_installed�s��������R�W�W�-�-�d�l�l�;�!�[�[�$�(�(�4�����B�!D�E���S��j�j��#������b�!��j�j��#���������d�+r*c��t|j�|jtj|j�|j�yrO�rr?rYrrrsr�rPs r(�test_no_pip_by_defaultz$EnsurePipTest.test_no_pip_by_default�s2���t�|�|�����d�k�k�4�<�<�8��%�%�'r*c��t|j�|jtj|jd��|j�y)NF)r�r�rPs r(�test_explicit_no_pipz"EnsurePipTest.test_explicit_no_pips7���t�|�|�����d�k�k�4�<�<�%��H��%�%�'r*c��ttjd�5}|j|j	�d�ddd�|jtjjtj��y#1swY�FxYw)Nr�r*)r`r:�devnullr�rarnr;rI)rKrbs  r(�test_devnullzEnsurePipTest.test_devnull	sW��
�"�*�*�d�
#�q����Q�V�V�X�s�+�$�	
��������r�z�z�2�3�$�
#�s�!B�B
c�X�t|j�t�5}d|d<d|d<tj�5}||d<d}d}d}|fD]�\}}t
jj||�}	tj|	�t
jj|	|�}
t|
d	�5}|j|�ddd���|j�5|jtj|j|d
��ddd�ddd�ddd�t
jjt
jj|j�|j |j"�}t%|dd
ddddddg	�\}
}|j'd�}|j)|d�|
j'd�}
dj+t-j.��}|j)|
dt1|�|�tj2|j�j'd�}|j5||
�t�5}|j�5d|d<t%|dd
dddddg�\}
}ddd�ddd�|j'd�}t7j8dd|t6j:��}	ddl}|j)|jA�d�|
j'd�}
|j5d|
�|s|jC�yy#1swY���xYw#1swY��*xYw#1swY��/xYw#1swY��4xYw#1swY��xYw#1swY��xYw#t>$r*t7j8dd|t6j:��}Y��wxYw)NrG�PYTHONWARNINGS�1�PIP_NO_INSTALL�HOMEz[global]
no-install=1)r�zpip.ini)z.pipzpip.confrT)r�r�z-Wzignore::DeprecationWarningzignore::ImportWarningr9r�r�z	--versionr�rzpip {}zensurepip._uninstallzl^(WARNING: )?The directory .* or its parent directory is not owned or is not writable by the current user.*$)�flagsrz<^WARNING: Disabling truststore since ssl support is missing$zSuccessfully uninstalled pip)"rr?rr=r�r:r;r[r�r`r��nicer_errorrYrrrsr<rArFr)r"r��format�	ensurepip�version�len�fsencoder��re�sub�	MULTILINE�ssl�ImportError�rstripr�)rKr��envvars�home_dir�
bad_config�win_location�posix_locationr��fname�dirpath�fpathrbr�r&r'�expected_versionr?r�s                  r(�do_test_with_pipzEnsurePipTest.do_test_with_pips0���t�|�|��
 �
"�g�)1�G�$�%�),�G�$�%��,�,�.�(�"*����5�
� 2��!5��'5�&7�N�G�U� �g�g�l�l�8�W�=�G��H�H�W�%��G�G�L�L��%�8�E��e�S�)�Q����
�+�*�)�	'8��%�%�'��)�)�$�+�+�t�|�|�?S�37�*�9�(�#/�#�F�����R�W�W�-�-�d�l�l�;�T�[�[�$�(�(�S�����.J��,�d��U�K�!)�*���S�
�j�j��#������b�!��j�j��#��#�?�?�9�+<�+<�+>�?������3�c�"2�3�4�6F�G��+�+�d�l�l�+�2�2�9�=���
�
�g�s�#�
!�
"�g��!�!�#�-5��(�)�'���6��1�4��0�)2�3���S�	$�#��j�j��#���f�f�N�OQ�����.��	)��	
�������r�*��j�j��#���
�
�4�c�:�$��)�)�+�$�E*�)��
(�'��#/�.��#�
"��l$�#��#�
"��0�	)��&�&�N���2�<�<�)�C�	)�s��M�A6M�5L*	�M�!.L7�M�M�M*�*M�M*�M6�*L4
�/M�7M�<M�M	�	M�M�M'	�#M*�*M3�60N)�(N)c#�K�	d��y#tj$rc}|jxsdjd��}|jxsdjd��}|j|�d|�d|���Yd}~yd}~wwxYw�w)z�
        Capture output from a failed subprocess for easier debugging.

        The output this handler produces can be a little hard to read,
        but at least it has all the details.
        Nr*�replace)�errorsz

**Subprocess Output**
z

**Subprocess Error**
)rr#rWr"r�fail)rK�excr&r's    r(r�zEnsurePipTest.nicer_errorss�����		����,�,�	��:�:�$��,�,�I�,�>�C��:�:�$��,�,�I�,�>�C��I�I��%�*�*-��/)�),��/�
�
��	�s+�B�	�B�A?�AA:�5B�:A?�?B�cpuc�H�|jd�|jd�y)NFT)r�rPs r(�
test_with_pipzEnsurePipTest.test_with_pip�s ��	
���e�$����d�#r*N)rerfrgrhr�r�r�r�r��
contextlib�contextmanagerr�r
rr�rjr*r(r�r��s^��/�
,�(�
(�
4�^,�@������$���u��$���$r*r��__main__rO)7rhr�r�r:�os.pathr�r�rr�rrBr�r=r!�test.supportrrrrrrr	r
rrr
�test.support.os_helperrrrrr�test.support.testcaserr�rr�
unittest.mockrr�ctypesr�r�r�r�rDrLr��SkipTestr)�TestCaser,rlr�re�mainrjr*r(�<module>r�sM�����	���	�
�
��
����E�E�E�E�
6�6�1���%���(�H�'�'��J�J�#�/�/�!�.�
���s�~�~�-�@�B��
�G�
�(�
�
�G�
H�H������&�x� � �/�&�PG
>��G
>�R�Z$�H�Z$��Z$�z�z���H�M�M�O���U��
�F��s�6D,�,D6�5D6

Youez - 2016 - github.com/yon3zu
LinuXploit