+
    Bi"                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIHtHtHtHtHtHtHtHtHtHtHtHt ^ RIHtHtHtHtH t  ^ RI!t!^ RI"t"^ RI#H$t$H%t%  ^ RI&t&]!PP                  ! ]
PR                  ]
PT                  8H  ;'       g    ]
PV                  ]
PX                  8g  R4      t-]'       g   ]'       g	   ]'       d   ]!P\                  ! R4      h]! 4       RR l4       t/ ! R R	]!P`                  4      t1 ! R
 R]14      t2]- ! R R]14      4       t3]4R8X  d   ]!Pj                  ! 4        R# R#   ]' d    Rt& Li ; i)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_androidis_apple_mobile	is_wasm32requires_venv_with_pipTEST_HOME_DIRrequires_resourcecopy_python_src_ignore)can_symlinkEnvironmentVarGuardrmtreeTESTFNFakePath)patchMockz:cannot run venv.create from within a venv on this platformz&venv is not available on this platformc                    \         P                  ! V \         P                  \         P                  / \        P                  CR R/CR7      pVP                  4       w  r4VP                  '       d\   \        '       d.   V'       d&   \        TP                  T;'       g    RR4      4       \         P                  ! VP                  WV4      hV'       d%   VP                  VR4      VP                  VR4      3# W43# )
PYTHONHOME )stdoutstderrenvutf-8backslashreplace)
subprocessPopenPIPEosenvironcommunicate
returncoder   printdecodeCalledProcessError)cmdencodingpouterrs   &&   %/usr/lib/python3.14/test/test_venv.pycheck_outputr-   0   s    ,rzz,<,	.A }}HC|||7s#**X002DEF++LL#C) 	)JJx!34JJx!34
 	
 8O    c                   \   a  ] tR t^Ct o RtRtR tR tRR/R ltR t	R t
R	R
/R ltRtV tR# )BaseTestzBase class for venv tests.c                x   \         P                  P                  \        P                  ! 4       4      V n        \         P                  R 8X  d   RV n        RV n        RV n	        M-RV n        RR\        P                  ! 4        23V n        RV n	        \        P                  p\         P                  P                  V4      R,          V n        \        P                   R8X  dT   \         P                  P#                  V4      '       d/   \         P                  P%                  V4      '       g
   RV n        R
# R	V n        R
# )ntScriptsIncludebinlibpythonincludewin32TFNLib)r    pathrealpathtempfilemkdtempenv_dirnamebindirr6   r8   	sysconfig_get_python_version_abisys_base_executablesplitexeplatformlexistsexistscannot_link_exe)self
executables   & r,   setUpBaseTest.setUpG   s    ww''(8(8(:;77d?#DKDH$DLDK	(I(I(K'LMNDH$DL))
77==,R0LLG#
++GGNN:..#'D #(D r.   c                0    \        V P                  4       R # N)r   rA   rN   s   &r,   tearDownBaseTest.tearDownZ   s    t||r.   real_env_dirFc                   V'       d+   \         P                  P                  V P                  4      pMV P                  p\         P                  P	                  W P
                  V P                  4      # rS   )r    r=   r>   rA   joinrC   rI   )rN   rW   rA   s   &$ r,   envpyBaseTest.envpy]   sC    gg&&t||4GllGww||G[[$((;;r.   c           	     
   \        4       ;_uu_ 4       p\        4       ;_uu_ 4       pV! V/ VB  R R R 4       R R R 4       XP                  4       XP                  4       3#   + '       g   i     L8; i  + '       g   i     LC; irS   )r   r   getvalue)rN   funcargskwargsoutputerrors   &&*,  r,   run_with_captureBaseTest.run_with_captured   s\    & ""ed%f% #   %.."222 #" s!   A2	A	A2A/*A22B	c                Z    \         P                  P                  ! V P                  .VO5!  # rS   )r    r=   rY   rA   rN   r_   s   &*r,   get_env_fileBaseTest.get_env_filej   s    ww||DLL0400r.   r(   r   c                   \        V P                  ! V!  R VR7      ;_uu_ 4       pVP                  4       pRRR4       V#   + '       g   i     X# ; i)rr(   N)openrg   read)rN   r(   r_   fresults   &$*  r,   get_text_file_contentsBaseTest.get_text_file_contentsm   sC    $##T*C(CCqVVXF D DCs   A  A	)rC   rM   rA   rI   r8   r6   Ni  )__name__
__module____qualname____firstlineno____doc__maxDiffrP   rU   rZ   rc   rg   rp   __static_attributes____classdictcell____classdict__s   @r,   r0   r0   C   s>     $G)&<E <31W  r.   r0   c                   j  a  ] tR t^rt o RtR tR tR tR tR t	R t
R t]R	 4       t]R
 4       t]]P                   ! ]! 4       R4      R 4       4       t]P(                  R8X  d   R7tM<R8R9R:RR]P,                  R,          ,          3RR]P,                  R,          ,          R33tR tR tR tR tR tR t]P                   ! ]! 4       R4      R 4       t]R 4       t]P                   ! ]! 4       R4      R 4       t]P@                  ! ]!PD                  R8H  R4      R 4       t#]P@                  ! ]!PD                  R8H  R4      R 4       t$]P                   ! ]!PD                  R8H  R4      R  4       t%]P                   ! ]!PD                  R8H  R4      R! 4       t&]P                   ! ]!PD                  R8H  ;'       d    ]! 4       R"4      R# 4       t']R$ 4       t(]R% 4       t)]P@                  ! ]!PD                  R8H  R&4      R' 4       t*]P                   ! ]P(                  R(8H  R)4      R* 4       t+R+ t,]P@                  ! ]!PD                  R8H  R&4      ]R, 4       4       t-]R- 4       t.]R. 4       t/]R/ 4       t0]R0 4       t1]R1 4       t2]R2 4       t3R3 t4]]P                   ! ]!PD                  R8H  R4      R4 4       4       t5R5t6V t7R6# );	BasicTestzTest venv module functionality.c                    V P                   ! V!  pV P                  \        P                  P	                  V4      4       R # rS   )rg   
assertTruer    r=   isdir)rN   r_   fns   &* r,   r   BasicTest.isdiru   s+    %b)*r.   c                    \        V P                  4       V P                  \        P                  V P                  4       V P                  4        R# )zA
Test the create function with default arguments and a str path.
N)r   rA   rc   venvcreate_check_output_of_default_createrT   s   &r,   test_defaults_with_str_path%BasicTest.test_defaults_with_str_pathy   s4     	t||dkk4<<8,,.r.   c                    \        V P                  4       V P                  \        P                  \        V P                  4      4       V P                  4        R# )zG
Test the create function with default arguments and a path-like path.
N)r   rA   rc   r   r   r   r   rT   s   &r,   test_defaults_with_pathlike%BasicTest.test_defaults_with_pathlike   s9     	t||dkk8DLL+AB,,.r.   c                   V P                  V P                  4       V P                  V P                  4       V P                   ! V P                  !   V P	                  R 4      p\
        P                  ! R4      ^8H  ;'       d/    \        P                  R8H  ;'       d    \        P                  R8g  pV'       d0   V P                  \        P                  P                  V4      4       M.V P                  \        P                  P                  V4      4       V P!                  R4      p\        P"                  p\        P                  P%                  V4      pV P'                  RV,          V4       V P'                  R\        P                  P)                  \        P*                  4      ,          V4       \        P                  R8X  d   RMR	pR
\        P*                   RV RV P,                   2pV P'                  Ws4       V P	                  V P                  V P.                  4      p\        P                  P                  V4      '       gT   V P	                  V P                  4      p	\1        RV	,          4       \1        R\        P2                  ! V	4      ,          4       V P                  \        P                  P                  V4      RV,          4       R# )lib64Pposixdarwin
pyvenv.cfgz	home = %szexecutable = %sr2   r   z	 --copiesz
command = z -m venvz* --without-pip --without-scm-ignore-files Contents of %r:    %rFile %r should exist.N)r   rC   r8   r6   rg   structcalcsizer    rB   rF   rJ   r   r=   islinkassertFalserL   rp   rG   dirnameassertInr>   rO   rA   rI   r$   listdir)
rN   r)   
conditionsdatarO   r=   copiesr'   r   bds
   &         r,   r   )BasicTest._check_output_of_default_create   s   

4;;

4<< 

DHHg&s+q0 1 1rww'7I 1 1||x/ 	OOBGGNN1-.RWW^^A./**<8))
wwz*kD($/'gg&&s~~678<	>ww}+CNN+8F8 <--1\\N<c t{{DHH5ww~~b!!""4;;/B#b()(RZZ^+,r*,Cb,HIr.   c                   R	R
RRRRRRRR\        4       3.	pV EF)  w  r#pV P                  W#VR7      ;_uu_ 4        \        V P                  4       V'       g   / pMW4/p\        P
                  ! R/ VB p\        4       Vn        \        4       Vn        V P                  VP                  V P                  4       V P                  R4      pV'       d   VP                  R4      '       d    R F  pV P                  VRV 24       K  	  M2\        P                  R8X  d	   VR8X  d   MV P!                  VRV 24       R R R 4       EK,  	  R #   + '       g   i     EKB  ; i)Nsymlinks--without-scm-ignore-filesscm_ignore_files)optattrvaluer   gitzcommand = .* r2   )NNN)z--copiesr   F)--without-pipwith_pipF)--system-site-packagessystem_site_packagesT)--clearclearT)	--upgradeupgradeT)--upgrade-depsupgrade_depsT)z--prompt="foobar"promptfoobar )r   r   r   r   z--prompt)	frozensetsubTestr   rA   r   
EnvBuilderr   upgrade_dependencies
_setup_piprc   r   rp   endswithassertNotRegexr    rB   assertRegex)rN   optionsr   r   r   r`   br   s   &       r,   test_config_file_command_key&BasicTest.test_config_file_command_key   s-   +0D&*45)+=y{K

 !(Cu#>>t||$F"]FOO-f-)-&#v%%ahh=22<@s||E22 >++D]3%2HI > WWd]tZ'7$$TmC5+AB% ?> !(>>>s   B-E	)AE		Ec                   \         P                  P                  V P                  4      ^,          p\	        V P                  4       \
        P                  ! 4       pV P                  VP                  V P                  4       VP                  V P                  4      pV P                  R4      pV P                  VP                  V4       V P                  RV4       \	        V P                  4       \
        P                  ! RR7      pV P                  VP                  V P                  4       VP                  V P                  4      pV P                  R4      pV P                  VP                  R4       V P                  RV4       \	        V P                  4       \
        P                  ! RR7      p\         P                  P                  \         P                   ! 4       4      pV P                  VP                  V P                  4       VP                  V P                  4      pV P                  R4      pV P                  VP                  V4       V P                  RV,          V4       R# )	   r   z	prompt = z	My prompt)r   zprompt = 'My prompt'
.zprompt = '%s'
N)r    r=   rH   rA   r   r   r   rc   r   ensure_directoriesrp   assertEqualr   assertNotInr   basenamegetcwd)rN   env_namebuildercontextr   cwds   &     r,   test_promptBasicTest.test_prompt   s   77==.q1t||//#gnndll;,,T\\:**<82d+t||//5gnndll;,,T\\:**<85.5t||//-ggryy{+gnndll;,,T\\:**<8-'#-t4r.   c           	     6  a a \         P                  ! 4       pR p\        P                  P	                  \
        P                  4      ^,          p\        P                  P                  \
        P                  4      p\
        P                  R8X  di   Rp\        P                  P                  \        P                  P                  V4      ^ ,          4      P                  R4      '       d   RpMRpVR,           p\        P                  ! 4       ;_uu_ 4       p\        P                  P                  \        P                  P                  WRV4      4      o\
        P                  R8X  d=   \        P                  P                  \        P                  P!                  S4      4      oVV 3R lpVP#                  V4      p\%        RV4      ;_uu_ 4        VP'                  V4       R	R	R	4       R	R	R	4       R	#   + '       g   i     L; i  + '       g   i     R	# ; i)
r5   r9   r3   _dpython_dr7   z.exec                 ^  < SP                  V R ,          . RO4       \        P                  P                  \        P                  P	                  V ^ ,          4      4      p\        P                  P                  \        P                  P	                  S4      4      pSP                  W#4       R# ):r   NNN)-mpipinstallr   r   )r   r    r=   normcaser   )r'   r`   exe_direxpected_dir
expect_exerN   s   &,  r,   pip_cmd_checker<BasicTest.test_upgrade_dependencies.<locals>.pip_cmd_checker   ss      G	 ''**277??3q6+BC!ww//
0KL  7r.   zvenv.subprocess.check_outputN)r   r   r    r=   rH   rF   rO   r   rG   rJ   r   splitextr   r?   TemporaryDirectoryrY   r>   r   r   r   )	rN   r   bin_path
python_exeexpected_exefake_env_dirr   fake_contextr   s	   f       @r,   test_upgrade_dependencies#BasicTest.test_upgrade_dependencies   sa   //#WW]]3>>215
ww''(<(<=<<7" Hww 0 0 <Q ?@II$OO)'%.J((**l))\\BJ ||w&WW--bgg.>.>z.JK
8 #55lCL5GG,,\: H/ +*. HG/ +**s%   B;HG4	"H4H?HH	c                   \        V P                  4       V P                  \        P                  V P                  4       V P                  4       RR.pRV P                  3RV P                  3R\        P                  3R\        P                  33 Fu  w  r#RV,          V^&   \        V4      w  rEV P                  \        P                  ! VP                  4       P                  4       4      \        P                  ! V4      V4       Kw  	  R# )z.
Test that the prefix values are as expected.
-cNprefixexec_prefixbase_prefixbase_exec_prefixzimport sys; print(sys.%s))r   rA   rc   r   r   rZ   rF   r   r   r-   r   pathlibPathstripr%   )rN   r'   r   expectedr*   r+   s   &     r,   test_prefixesBasicTest.test_prefixes  s     	t||dkk4<<8zz|T4(t||$DLL)COO,!5!56	!8F
 169CF#C(HCW\\#))+*<*<*>?$\\(3V=!8r.   c                   \        V P                  4       V P                  \        P                  V P                  RR7       V P                  4       RR.pRRR\        \        P                  ! 4       4      3R\        P                  ! 4       3R\        P                  ! 4       3R\        \        P                  ! R	4      4      33 Fb  w  r#V P                  V4      ;_uu_ 4        R
V,          V^&   \        VRR7      w  rEV P                  VP                  4       W54       RRR4       Kd  	  RV P                  4       3R\         P"                  33 F_  w  rcV P                  V4      ;_uu_ 4        RV R2V^&   \        VRR7      w  rEV P                  VP                  4       W54       RRR4       Ka  	  R#   + '       g   i     EK  ; i  + '       g   i     K  ; i)B
Test that the sysconfig functions work in a virtual environment.
Fr   r   Nis_python_build()get_makefile_filename()get_config_h_filename()!get_config_var("Py_GIL_DISABLED")Py_GIL_DISABLED%import sysconfig; print(sysconfig.%s)r   rk   rO   rG   import sys; print(sys.)zget_preferred_scheme("prefix")r   zget_default_scheme()r   )r   rA   rc   r   r   rZ   strrD   is_python_buildget_makefile_filenameget_config_h_filenameget_config_varr   r-   r   r   rF   rG   rN   r'   callr   r*   r+   r   s   &      r,   test_sysconfigBasicTest.test_sysconfig  s   
 	t||dkk4<<%Hzz|T4( 7, #i&?&?&A"BC&	(G(G(IJ&	(G(G(IJ0))*;<=?	@ND d##@4GA'g>  h< $#	@ 4::<(  !5!56	
ND d##1$q9A'g>  h< $#
	 $## $##s   "<F3,9G3GGzNeeds symlinksc                   \        V P                  4       V P                  \        P                  V P                  RR7       V P                  4       RR.pRRR\        \        P                  ! 4       4      3R\        P                  ! 4       3R\        P                  ! 4       3R\        \        P                  ! R	4      4      33 Fb  w  r#V P                  V4      ;_uu_ 4        R
V,          V^&   \        VRR7      w  rEV P                  VP                  4       W54       RRR4       Kd  	  RV P                  4       33 F_  w  rcV P                  V4      ;_uu_ 4        RV R2V^&   \        VRR7      w  rEV P                  VP                  4       W54       RRR4       Ka  	  R#   + '       g   i     K  ; i  + '       g   i     K  ; i)r   Tr   r   Nr   r   r   r   r   r   r   rk   rO   r   r   r   r   )r   rA   rc   r   r   rZ   r   rD   r   r  r  r  r   r-   r   r   r  s   &      r,   test_sysconfig_symlinks!BasicTest.test_sysconfig_symlinks?  s{    	t||dkk4<<$Gzz|T4( 7, #i&?&?&A"BC&	(G(G(IJ&	(G(G(IJ0))*;<=?	@ND d##@4GA'g>  h< $#	@ 4::<(
ND d##1$q9A'g>  h< $#
	 $## $##s   "<F"9F6"F36Gr9   site-packagesr6   zpython%d.%d:N   Nc                ^   V F  p\         P                  P                  ! V P                  .VO5!  p\         P                  ! V4       \         P                  P                  WB4      p\        VR4      ;_uu_ 4       pVP                  R4       RRR4       K  	  R#   + '       g   i     K  ; i)zV
Create some files in the environment which are unrelated
to the virtual environment.
wb   Still here?N)r    r=   rY   rA   mkdirrl   write)rN   pathsfilenamesubdirsdr   rn   s   &&&    r,   create_contentsBasicTest.create_contentsr  sp    
 GT\\4G4AHHQKa*Bb$1'  	   s   ;BB,c                V   V P                  V P                  R4       \        P                  ! V P                  4       V P                   F  p\
        P                  P                  ! V P                  .VR,           O5!  pV P                  \
        P                  P                  V4      4       \        VR4      ;_uu_ 4       pV P                  VP                  4       R4       RRR4       K  	  \        P                  ! RR7      pVP                  V P                  4       V P                   Fd  p\
        P                  P                  ! V P                  .VR,           O5!  pV P                  \
        P                  P                  V4      4       Kf  	  R#   + '       g   i     EK_  ; i)z5
Test creating environment in an existing directory.
foorbr  NTr   )r  )r  ENV_SUBDIRSr   r   rA   r    r=   rY   r   rL   rl   r   rm   r   r   )rN   r  r   rn   r   s   &    r,   test_overwrite_existing!BasicTest.test_overwrite_existing~  s    	T--u5DLL!''GdllBg.@BBOOBGGNN2./b$1  >:   ( //-t||$''GdllBg.@BBRWW^^B/0 (  s   !FF(c                   \         P                  ! V4       F  p\         P                  P                  W4      p\         P                  P	                  V4      '       g&   \         P                  P                  V4      '       d   \         P                  ! V4       K  \         P                  P                  V4      '       g   K  \        V4       K  	  R # rS   )	r    r   r=   rY   r   isfileremover   r   )rN   r=   r   s   && r,   clear_directoryBasicTest.clear_directory  sq    **T"Bd'Bww~~b!!RWW^^B%7%7		"r""r
 #r.   c                   V P                   R ,           F  p\        P                  P                  ! V P                  .VO5!  p\        VR4      ;_uu_ 4       pVP                  R4       RRR4       V P                  \        \        3\        P                  V P                  4       V P                  V P                  4       K  	  R#   + '       g   i     Lf; i):N   Nr  r.   N)r  r    r=   rY   rA   rl   r  assertRaises
ValueErrorOSErrorr   r   r"  )rN   r  r   rn   s   &   r,   test_unoverwritable_fails#BasicTest.test_unoverwritable_fails  s    %%b))Edll3U3Bb$1  z73T[[$,,O  . *s   CCc                   R EFe  p\         P                  ! VR7      pV P                  VP                  V P                  4       V P                  V P                  4       V P                  V P                  4       V P
                  ! V P                  !   V P                  V P                  V P                  4      p\        P                  P                  V4      '       gT   V P                  V P                  4      p\        RV,          4       \        R\        P                  ! V4      ,          4       V P!                  \        P                  P                  V4      RV,          4       EKh  	  R# )z3
Test upgrading an existing environment directory.
)r   r   r   r   NFT)r   r   rc   r   rA   r   rC   r8   r6   rg   rI   r    r=   rL   r$   r   r   )rN   r   r   r   r   s   &    r,   test_upgradeBasicTest.test_upgrade  s     %Goog6G!!'..$,,?JJt{{#JJt||$JJ!""4;;9B77>>"%%&&t{{3'",-hB/0OOBGGNN2.0G"0LM %r.   c                    R Fb  w  r\         P                  ! RVR7      pVP                  V P                  4       V P	                  R4      pV P                  RV,          V4       Kd  	  R# )z*
Test isolation from system site-packages
T)r   r   r   z"include-system-site-packages = %s
N))Ttrue)Ffalse)r   r   r   rA   rp   r   )rN   sspsr   r   s   &    r,   test_isolationBasicTest.test_isolation  sT     9FCooDsKGNN4<<(..|<DMM?!CTJ	 9r.   c                   R F  p\         P                  ! RVR7      pVP                  V P                  4       V P	                  V P
                  V P                  4      pV'       g   Kf  V P                  '       d1   V P                  \        P                  P                  V4      4       K  V P                  \        P                  P                  V4      4       K  	  R# )z#
Test symlinking works as expected
Tr   r   Nr,  )r   r   r   rA   rg   rC   rI   rM   r   r    r=   r   r   )rN   uslr   r   s   &   r,   test_symlinkingBasicTest.test_symlinking  s    
 !CooD3?GNN4<<(""4;;9B s''' $$RWW^^B%78OOBGGNN2$67 !r.   c                $   \        V P                  4       V P                  \        P                  V P                  4       V P                  RR7      p\        VRR.4      w  r#V P                  VP                  4       VP                  4       4       R# )4
Test that the sys.executable value is as expected.
TrW   r   !import sys; print(sys.executable)N)
r   rA   rc   r   r   rZ   r-   r   r   encode)rN   rZ   r*   r+   s   &   r,   test_executableBasicTest.test_executable  sl    
 	t||dkk4<<8


-/!1 2elln5r.   c                6   \        V P                  4       \        P                  ! RRR7      pVP	                  V P                  4       V P                  RR7      p\        VRR.4      w  r4V P                  VP                  4       VP                  4       4       R# )r<  Tr7  r=  r   r>  N)
r   rA   r   r   r   rZ   r-   r   r   r?  )rN   r   rZ   r*   r+   s   &    r,   test_executable_symlinks"BasicTest.test_executable_symlinks  st    
 	t||//t<t||$


-/!1 2elln5r.   r2   z&contains invalid characters on Windowsc                   \        V P                  4       \        P                  ! R4      pVf   V P	                  R4       Rp\
        P                  P                  \
        P                  P                  V P                  4      V4      p\        P                  ! RR7      pVP                  V4       \
        P                  P                  W0P                  R4      p\
        P                  P                  V P                  R4      p\        VR	4      ;_uu_ 4       pVP                  R
\        P                   ! V4       R24       RRR4       \#        W.4      w  rVP%                  4       p
V P'                  VP)                  4       V
^ ,          9   4       V P+                  V
^,          VP)                  4       4       R#   + '       g   i     L; i)z;
Test that the template strings are quoted properly (bash)
bashNbash required for this test
"';&&$e|'"Tr  activateztest_special_chars.shwsource r
python -c 'import sys; print(sys.executable)'
python -c 'import os; print(os.environ["VIRTUAL_ENV"])'
deactivate
r   rA   shutilwhichskipTestr    r=   rY   r>   r   r   r   rC   rl   r  shlexquoter-   
splitlinesr   r?  assertEndsWith)rN   rF  r   rA   r   rI  test_scriptrn   r*   r+   liness   &          r,   test_special_chars_bash!BasicTest.test_special_chars_bash  s>   
 	t||||F#<MM78!'',,rww//=xH//-w77<<jAggll4<<1HI+s##qGGgekk(34 5# # $ $
   34 )U1X56E!Hhoo&78 $#s   *F<<G	c                   \        V P                  4       \        P                  ! R4      ;'       g    \        P                  ! R4      pVf   V P	                  R4       Rp\
        P                  P                  \
        P                  P                  V P                  4      V4      p\        P                  ! RR7      pVP                  V4       \
        P                  P                  W0P                  R4      p\
        P                  P                  V P                  R	4      p\        VR
4      ;_uu_ 4       pVP                  R\        P                   ! V4       R24       RRR4       \#        W.4      w  rVP%                  4       p
V P'                  VP)                  4       V
^ ,          9   4       V P+                  V
^,          VP)                  4       4       R#   + '       g   i     L; i)z:
Test that the template strings are quoted properly (csh)
tcshcshNzcsh required for this testrH  Tr  zactivate.cshztest_special_chars.cshrJ  rK  rL  rM  )rN   r[  r   rA   r   rI  rU  rn   r*   r+   rV  s   &          r,   test_special_chars_csh BasicTest.test_special_chars_csh  sO   
 	t||ll6"99fll5&9;MM67!'',,rww//=xH//-w77<<nEggll4<<1IJ+s##qGGgekk(34 5# # $ $
   23 )U1X56E!Hhoo&78 $#s   8*GG*	zonly relevant on Windowsc                T   \        V P                  4       Rp\        P                  P	                  \        P                  P                  V P                  4      V4      p\        P                  ! RR7      pVP                  V4       \        P                  P	                  W P                  R4      p\        P                  P	                  V P                  R4      p\        VR4      ;_uu_ 4       pVP                  RV RV P                   R	V P                   R
24       RRR4       \        V.4      w  rxVP                  4       p	V P                  VP!                  4       V	^ ,          9   4       V P#                  V	^,          VP!                  4       4       R#   + '       g   i     L; i)z?
Test that the template strings are quoted properly on Windows
z'&&^$eTr  activate.batztest_special_chars.batrJ  z@echo off
"z" & z* -c "import sys; print(sys.executable)" & z> -c "import os; print(os.environ['VIRTUAL_ENV'])" & deactivateN)r   rA   r    r=   rY   r>   r   r   r   rC   rl   r  rI   r-   rS  r   r?  rT  )
rN   r   rA   r   rI  
test_batchrn   r*   r+   rV  s
   &         r,   test_special_chars_windows$BasicTest.test_special_chars_windows&  s.   
 	t||'',,rww//=xH//-w77<<nEWW\\$,,0HI
*c""aGG  zxxj Jxxj !!! " #  - )U1X56E!Hhoo&78 #"s   /0FF'	c                   \        V P                  4       \        P                  P	                  \        P                  P                  V P                  4      R4      p\        P                  ! RR7      pVP                  V4       \        P                  P	                  WP                  R4      p\        VRV P                  RR.RR	7      w  rEV P                  VP                  4       R
4       R# )z 
Test handling of Unicode paths
u   ϼўТλФЙTr  r_  &r   zprint(0)oemrk   0N)r   rA   r    r=   rY   r>   r   r   r   rC   r-   rI   r   r   )rN   rA   r   rI  r*   r+   s   &     r,   test_unicode_in_batch_file$BasicTest.test_unicode_in_batch_file=  s    
 	t||'',,rww//=~N//-w77<<nEsDHHdJ7
 	c*r.   zsymlinks on Windowsc           	        \        V P                  4       \        P                  P	                  \        P                  P                  V P                  4      R4      p\        R4      ;_uu_ 4       p\        4       Vn        \        P                  ! RRR7      pV P                  VP                  V4      w  rERpV P                  VRV RV 24       RRR4       R#   + '       g   i     R# ; i)	z.
Test handling of failed symlinks on Windows.
r   z
os.symlinkTr7  z%'[A-Z]:\\\\(?:[^\\\\]+\\\\)*[^\\\\]+'zUnable to symlink z to N)r   rA   r    r=   rY   r>   r   r(  side_effectr   r   rc   r   r   )rN   rA   mock_symlinkr   _r+   filepath_regexs   &      r,   test_failed_symlinkBasicTest.test_failed_symlinkM  s     	t||'',,rww//=vF<  L'.yL$ooD4@G**7>>7CFAENS%77GtNK["\] !   s   0A CC+	c                4   \        4        \        V P                  4       V P                  \        P
                  V P                  4       \        V P                  RR7      RR.4      w  rV P                  VP                  4       RP                  4       4       R# )z1
Test that the multiprocessing is able to spawn.
Tr=  r   zrfrom multiprocessing import Pool; pool = Pool(1); print(pool.apply_async("Python".lower).get(3)); pool.terminate()r7   N)r   r   rA   rc   r   r   r-   rZ   r   r   r?  rN   r*   r+   s   &  r,   test_multiprocessingBasicTest.test_multiprocessing\  sr     	34t||dkk4<<8!>!  !
 	hoo&78r.   c                2   \        4        \        V P                  4       V P                  \        P
                  V P                  4       \        P                  P                  \        R4      p\        P                  ! V P                  RR7      RV.4       R# )z7
Test that the multiprocessing is able to spawn itself
z_test_venv_multiprocessing.pyTr=  -IN)r   r   rA   rc   r   r   r    r=   rY   r   r   
check_callrZ   )rN   scripts   & r,   test_multiprocessing_recursion(BasicTest.test_multiprocessing_recursiono  sc    
 	34t||dkk4<<8m-LMtzztz<dFKLr.   znot relevant on Windowsc                   \         P                  ! R 4      pVf   V P                  R4       \        V P                  4       \
        P                  ! RR7      pVP                  V P                  4       \        P                  P                  V P                  V P                  R4      p\        P                  P                  V P                  R4      p\        VR4      ;_uu_ 4       pVP                  RV R	24       RRR4       \        W.4      w  rgV P                  VR
P!                  4       4       V P                  VR
P!                  4       4       R#   + '       g   i     L`; i)rF  NrG  Tr  rI  ztest_strict.shrJ  zset -euo pipefail
source z
deactivate
r   )rN  rO  rP  r   rA   r   r   r   r    r=   rY   rC   rl   r  r-   r   r?  )rN   rF  r   rI  rU  rn   r*   r+   s   &       r,   %test_deactivate_with_strict_bash_opts/BasicTest.test_deactivate_with_strict_bash_opts{  s    ||F#<MM78t||//-t||$77<<dkk:Fggll4<<1AB+s##qGG &Z (## $ $   34biik*biik* $#s   &EE$	r   zonly relevant on macOSc                ,   \        V P                  4       \        P                  ! 4       pVP	                  V P                  4       \        V P                  R R7      RR.4      w  r#V P                  VP                  4       RP                  4       4       R# )Tr=  r   z5import os; print("__PYVENV_LAUNCHER__" in os.environ)FalseN)
r   rA   r   r   r   r-   rZ   r   r   r?  )rN   r   r*   r+   s   &   r,   test_macos_envBasicTest.test_macos_env  sl    t||//#t||$!>C!E Fgnn&67r.   c                   \        V P                  4       V P                  \        P                  ,           pV P	                  \
        \        P                  V4       V P	                  \
        \        P                  \        V4      4       R# )zV
Test that venv creation fails when the target directory contains
the path separator.
N)	r   rA   r    pathsepr&  r'  r   r   r   )rN   bad_itempaths   & r,   test_pathsep_errorBasicTest.test_pathsep_error  sS    
 	t||||bjj0*dkk<@*dkk8L3IJr.   c           	        \        V P                  4       \        P                  p\        P
                  P                  \        P                  ! 4       4      pV P                  \         V4       \        P
                  P                  W P                  4      p\        P                  ! V4       \        P
                  P                  \        P                  4      p\        P                   ! \        P                  \        P
                  P                  W44      4       \        P
                  P                  W!V P"                  ^,          4      p\        P$                  ! V4       \        P
                  P                  VR4      p\&        P(                  ! R4      '       d   RMRpR\        P*                  P,                   \        P*                  P.                   V 2p\        P
                  P                  VVV4      p	. p
\        P
                   EF  pVP1                  R4      '       d^   \        P
                  P3                  V4      '       d7   \        P4                  ! V\        P
                  P                  W!4      4       Kv  Kx  \        P
                  P3                  \        P
                  P                  VR4      4      '       d   \        P6                  ! V4      p\9        W4      pV F  pW9   d   K  VR8X  d   K  \        P
                  P                  W4      p\        P
                  P3                  V4      '       d   \        P:                  ! W4       Kp  \        P
                  P=                  V4      '       g   K  \        P>                  ! V\        P
                  P                  W^4      \8        R7       K  	  EK  V
PA                  V4       EK  	  \        P
                  P                  W P                  V4      R	R
RRV P                  .p\        PB                  P                  V
4      p\&        P(                  ! R4      pV'       d   \&        PD                  ! 4       '       dK   \        P
                  PG                  \        P
                  PI                  \        P                  4      4      p\        PJ                  R8X  d   RpMRpRVVV/p\        PL                  PO                  R4      ;p'       d   VVR&   \P        PR                  ! VVR7       \        P
                  P                  V P                  V P                  V4      pVRRR.p\U        V4      w  ppV PW                  V	PY                  4       V9   4       R# )zZ
Test that when create venv from non-installed python, the zip path
value is as expected.
zos.pyr   tr   r7   z.zipr  )ignorer   r   r   r   LIBDIRr   DYLD_LIBRARY_PATHLD_LIBRARY_PATH
PYTHONPATHASAN_OPTIONS)r   z-Sr   zimport sys; print(sys.path)N)-r   rA   rF   
platlibdirr    r=   r>   r?   r@   
addCleanuprY   rC   r  r   rO   rN  copy2r6   makedirsrD   r  version_infomajorminorr   r   copyfiler   r   copyr   copytreeappendr  r   abspathr   rJ   r!   getr   rv  r-   r   r?  )rN   r  non_installed_dirrC   r   libdirlandmark
abi_thread
stdlib_zipzip_landmark'additional_pythonpath_for_non_installedeachpathnamesignored_namesrB   r   r'   
pythonpathld_library_pathld_library_path_env	child_envasan_optionstarget_pythonr*   r+   s   &                        r,   %test_zippath_from_non_installed_posix/BasicTest.test_zippath_from_non_installed_posix  s    	t|| ^^
GG,,X-=-=-?@ 12/=
WW%%cnn5
S^^RWW\\&%EF/TXXa[I
F77<<0%445FGGSR
c..445c6F6F6L6L5Mj\Z
ww||$5$.$.0 35/ H  ((77>>(++OO %6CE , Xw ?@@

8, 6x G!D, . h5Bww~~b))B/r**BGGLL,F/EG " 8>>+ !. ww||-{{JG+|| ZZ__35

 $228<)";";"="= ggoobggoocnn.MNO<<8#"5"3j#_
	 ::>>.99<9(4In%cy1 T\\4;;
KdD*GH$S++-45r.   c                   \         P                  ! V P                  4      p\        V4       V P                  vw  r#W,          R,          p\
        P                  ! V4       \        VR4      ;_uu_ 4       p\        V^4       F  w  rgRV 2pV P                  VRV4       K  	  RRR4       R#   + '       g   i     R# ; i)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.
rI  r  zCR LF found in line s   
N)
r   r   rA   r   r  r   r   rl   	enumerateassertNotEndsWith)	rN   venv_dirscripts_dirrl  script_pathrw  ilineerror_messages	   &        r,   .test_activate_shell_script_has_no_dos_newlines8BasicTest.test_activate_shell_script_has_no_dos_newlines  s     <<-x"..+,z9H+t$$$VQ/"6qc :&&tWmD 0 %$$$s   4.B,,B=	c                    V P                  \        P                  V P                  R0R7       V P	                  R4      P                  4       pV P                  RV4       R# )z~
        Test that a .gitignore file is created when "git" is specified.
        The file should contain a `*
` line.
        r   r   
.gitignore*N)rc   r   r   rA   rp   rS  r   )rN   
file_liness   & r,   test_scm_ignore_files_git#BasicTest.test_scm_ignore_files_git  sO     	dkk4<<05w 	 	800>IIK
c:&r.   c                V  aa RoRo ! VV3R lR\         P                  4      pV! RR0R7      pV P                  VP                  V P                  4       V P                  R4      P                  4       pV P                  R	V4       V P                  S4      pV P                  VS4       R
# )z=
Test that ``scm_ignore_files`` can work with multiple SCMs.
z
.bzrignorez# For Bazaar.
*
c                   0   <a  ] tR tRt o VV3R ltRtV tR# )FBasicTest.test_create_scm_ignore_files_multiple.<locals>.BzrEnvBuilderi  c                   < \         P                  P                  VP                  S4      p\	        VR RR7      ;_uu_ 4       pVP                  S4       RRR4       R#   + '       g   i     R# ; i)rJ  r   rk   N)r    r=   rY   rA   rl   r  )rN   r   gitignore_pathfilebzrignore_namecontentss   &&  r,   create_bzr_ignore_file]BasicTest.test_create_scm_ignore_files_multiple.<locals>.BzrEnvBuilder.create_bzr_ignore_file  sH    !#goo~!N.#@@DJJx( A@@@s   AA/	r   N)rr   rs   rt   ru   r  rx   ry   )r{   r  r  s   @r,   BzrEnvBuilderr    s     ) )r.   r  r   bzrr  r  r  N)	r   r   rc   r   rA   rp   rS  r   r   )rN   r  r   gitignore_lines	bzrignorer  r  s   &    @@r,   %test_create_scm_ignore_files_multiple/BasicTest.test_create_scm_ignore_files_multiple  s    
 &'	) 	)DOO 	)  %@gnndll;55lCNNPc?+//?	H-r.   c                0   V P                  \        P                  V P                  4       V P	                  \
        4      ;_uu_ 4        V P                  R4       RRR4       V P                  RV P                  R4      4       R#   + '       g   i     L3; i)zS
Test that no default ignore files are created when ``scm_ignore_files``
is empty.
r  Nr   r   )rc   r   r   rA   r&  FileNotFoundErrorrp   r   rT   s   &r,   "test_create_scm_ignore_files_empty,BasicTest.test_create_scm_ignore_files_empty-  sj     	dkk4<<8011''5 2 	211,?	A 21s   BB	c                    V P                  \        P                  RV P                  .4       V P	                  R4      P                  4       pV P                  RV4       R# )zH
Test that default SCM ignore files are created by default via the CLI.
r   r  r  N)rc   r   mainrA   rp   rS  r   )rN   r  s   & r,   test_cli_with_scm_ignore_files(BasicTest.test_cli_with_scm_ignore_files;  sH    
 	dii/4<<)HI55lCNNPc?+r.   c                    RRV P                   .pV P                  \        P                  V4       V P	                  \
        4      ;_uu_ 4        V P                  R4       RRR4       R#   + '       g   i     R# ; i)zK
Test that ``--without-scm-ignore-files`` doesn't create SCM ignore files.
r   r   r  N)rA   rc   r   r  r&  r  rp   rf   s   & r,   !test_cli_without_scm_ignore_files+BasicTest.test_cli_without_scm_ignore_filesE  sX    
  !=t||Ldii.011''5 2111s   A))A:	c           	        \         P                  P                  p\        P                  R 8X  d   R\
        \
        3R\
        P                  ! 4       \
        P                  ! 4       3.p^ RIp\        P                  ! R4      pV'       d,   . VORWD3NRVP                  V4      VP                  V4      3NpM8R\
        \
        3R\
        P                  ! 4       \
        P                  ! 4       3.pV Fd  w  rVpV P                  V RV 24      ;_uu_ 4        V'       d   V P                  V! Wg4      4       MV P                  V! Wg4      4       RRR4       Kf  	  R#   + '       g   i     K{  ; i)r9   TNProgramFilesF-)r   r   
_same_pathrF   rJ   r   lowerupper_winapir    getenvGetShortPathNameGetLongPathNamer   r   r   )rN   	same_pathtestsr  	progfilesrj   path1path2s   &       r,   test_venv_same_pathBasicTest.test_venv_same_pathP  s-   OO..	<<7" vv&v||~v||~6E 		.1I90 733I>@W@WXa@bc vv&7E  %OAeq011OOIe$;<$$Yu%<=	 21  %111s   8EE+c                   \        V P                  4       \        P                  ! V P                  4       V P                  pRV9   d   RV9   g   VP                  RR4      p\        P                  P                  V P                  V P                  V4      p \        P                  ! VRRV,          .4       R#   \        P                   d    T P                  RT,          4        R# i ; i)z1
Test that the GUI launcher runs the GUI python.
r7   pythonwr   z6import sys; assert sys._base_executable.endswith('%s')z venvwlauncher.exe did not run %sN)r   rA   r   r   rI   replacer    r=   rY   rC   r   rv  r&   fail)rN   exenameenvpyws   &  r,   test_venvwlauncherBasicTest.test_venvwlaunchero  s     	t||DLL!((wyG';ooh	:GdllDKKA	D!!64 2=?F2G #H I,, 	DII87BC	Ds    B: :-C+*C+r   N))r3   )r4   r:   )r;   r  )r5   )r8   )r6   )8rr   rs   rt   ru   rv   r   r   r   r   r   r   r   requireVenvCreater   r  unittest
skipUnlessr   r	  rF   rJ   r  r  r  r  r"  r)  r-  r4  r9  r@  rC  skipIfr    rB   rW  r\  ra  rg  rn  rr  rx  r{  r  r  r  r  r  r  r  r  r  r  r  rx   ry   rz   s   @r,   r}   r}   r   s    )+//J:CB58&;P = =$ = =@ (89= : =B ||w
 MC$4$4R$889MC$4$4R$88/J

(1$/N*K (898 :8. 	6 	6 (89
6 :
6 __RWW_&NO9 P92 __RWW_&NO9 P92 D*DE9 F9, D*DE+ F+ D::[].0^0^ 9 9$ 	M 	M __RWW_&?@+ A+$ 13KL8 M8K __RWW_&?@T6  AT6l E E  ' ' . ., A A , , 6 6>> D*DED F Dr.   r}   c                      a  ] tR tRt o RtR tR tR tR tR t	]
P                  R 4       t]! 4       ]! R	4      R
 4       4       tRtV tR# )EnsurePipTesti  z%Test venv module installation of pip.c                    \        V P                  R R7      RR.4      w  rVP                  R4      pV P                  VR4       VP                  R4      pV P                  VP	                  4       R4       R# )Tr=  r   z1try:
 import pip
except ImportError:
 print("OK")latin-1r   OKN)r-   rZ   r%   r   r   rq  s   &  r,   assert_pip_not_installed&EnsurePipTest.assert_pip_not_installed  sk    !>B!D E jj#b!jj#d+r.   c                    \        V P                  4       V P                  \        P                  V P                  4       V P                  4        R # rS   r   rA   rc   r   r   r  rT   s   &r,   test_no_pip_by_default$EnsurePipTest.test_no_pip_by_default  s2    t||dkk4<<8%%'r.   c                    \        V P                  4       V P                  \        P                  V P                  R R7       V P                  4        R# )F)r   Nr  rT   s   &r,   test_explicit_no_pip"EnsurePipTest.test_explicit_no_pip  s7    t||dkk4<<%H%%'r.   c                :   \        \        P                  R 4      ;_uu_ 4       pV P                  VP	                  4       R4       RRR4       V P                  \        P                  P                  \        P                  4      4       R#   + '       g   i     LN; i)r  r.   N)rl   r    devnullr   rm   r   r=   rL   )rN   rn   s   & r,   test_devnullEnsurePipTest.test_devnull  sZ    
 "**d##qQVVXs+ $ 	rzz23 $#s   !B

B	c                   \        V P                  4       \        4       ;_uu_ 4       pR VR&   RVR&   \        P                  ! 4       ;_uu_ 4       pW2R&   RpRpRpV3 F  w  rx\
        P                  P                  W74      p	\
        P                  ! V	4       \
        P                  P                  W4      p
\        V
R4      ;_uu_ 4       pVP                  V4       RRR4       K  	  V P                  4       ;_uu_ 4        V P                  \        P                  V P                  VR	R
7       RRR4       RRR4       RRR4       \        V P!                  R	R7      RRRRRRRR.	4      w  rVP#                  R4      pV P%                  VR4       VP#                  R4      pRP'                  \(        P*                  ! 4       4      pV P-                  W4       \
        P.                  ! V P                  4      P#                  R4      pV P1                  W4       \        4       ;_uu_ 4       pV P                  4       ;_uu_ 4        R VR&   \        V P!                  R	R7      RRRRRRR.4      w  rRRR4       RRR4       VP#                  R4      p\2        P4                  ! RRV\2        P6                  R7      p ^ RIpV P%                  VP=                  4       R4       VP#                  R4      pV P1                  RV4       V'       g   V P?                  4        R# R#   + '       g   i     EK  ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL ; i  + '       g   i     EL; i  + '       g   i     EL; i  \:         d-    \2        P4                  ! RRT\2        P6                  R7      p ELi ; i)r  PYTHONWARNINGS1PIP_NO_INSTALLHOMEz[global]
no-install=1r   rJ  NT)r   r   r=  z-Wzignore::DeprecationWarningzignore::ImportWarningru  r   z	--versionr  r   zpip {}zensurepip._uninstallzl^(WARNING: )?The directory .* or its parent directory is not owned or is not writable by the current user.*$)flagsz<^WARNING: Disabling truststore since ssl support is missing$zSuccessfully uninstalled pip)r   zpip.ini)z.pipzpip.conf) r   rA   r   r?   r   r    r=   rY   r  rl   r  nicer_errorrc   r   r   r-   rZ   r%   r   format	ensurepipversionassertStartsWithfsencoder   resub	MULTILINEsslImportErrorrstripr  )rN   r   envvarshome_dir
bad_configwin_locationposix_locationr   fnamedirpathfpathrn   r*   r+   expected_versionrA   r  s   &&               r,   do_test_with_pipEnsurePipTest.do_test_with_pip  s   t|| ""g )1G$% ),G$% ,,..("*5
  2!5'5&7NG ggll8=GHHW%GGLL8EeS))Q
+ *)	 '8 %%''))$++t||?S37 * 9 (# / #H  !>1,dUK!) * jj#b!jj##??9+<+<+>?c4++dll+229=g#
 !""g!!## -5()')F6140)2 3	 $ # jj# ff NOQ.	) 	r* jj#4c: $))+ $E *))
 (''# /.. #""l $## #""0  	)&&N2<<)C	)s   (MA;M	L$M	.L./M	7M(M>+M*	,M>6N L+$
M	.L?9	M	M	MM'	*M;5	M>>N	3O	O	c              #  (  "    Rx  R#   \         P                   dq   pTP                  ;'       g    RP                  RR7      pTP                  ;'       g    RP                  RR7      pT P                  T RT RT 24        Rp?R# Rp?ii ; i5i)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.   r  )errorsz

**Subprocess Output**
z

**Subprocess Error**
)r   r&   ra   r%   r   r  )rN   excr*   r+   s   &   r,   r  EnsurePipTest.nicer_error  s     		,, 	::$$,,I,>C::$$,,I,>CII% **- /)),/ 	s0   B
 BB8B
,B
B
BBcpuc                J    V P                  R 4       V P                  R4       R# )FTN)r$  rT   s   &r,   test_with_pipEnsurePipTest.test_with_pip  s      	e$d#r.   r   N)rr   rs   rt   ru   rv   r  r   r  r  r$  
contextlibcontextmanagerr  r
   r   r,  rx   ry   rz   s   @r,   r  r    sa     /,(
(
4^,@  $ u$  $r.   r  __main__rS   )6rv   r.  r  r    os.pathr   r  rN  r   r   rF   rD   r?   rQ  test.supportr   r   r   r   r   r   r   r	   r
   r   r   r   test.support.os_helperr   r   r   r   r   r  r   unittest.mockr   r   ctypesr  r  r   r   rG   rO   r  SkipTestr-   TestCaser0   r}   r  rr   r  r   r.   r,   <module>r8     sK     	   	    
   E E E E6 6   % ''JJ#//! . .
s~~-@B 
 I


D
EE $-x   -^ND NDb X$H X$ X$v zMMO y  Fs   2E 	EE