+
    Bi\                     |   R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RIH
t
 ^ RIHtH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t^ R	IHt ^ R
IHt ]P>                  P@                  '       d   ]PB                  ! R4      h^ RI"t"]"PF                  RJt$Rs%R t&R t' ! R R]PP                  4      t) ! R R]*4      t+ ! R R]PP                  4      t, ! R R]PP                  4      t- ! R R]PP                  4      t.]/R8X  d   ]P`                  ! 4        R# R# )zTests for 'site'.

Tests assume the initial paths in sys.path once the interpreter has begun
executing have not been removed.

N)support)assert_python_ok)import_helper)	os_helper)socket_helper)captured_stderr)TESTFNEnvironmentVarGuard)mock)copyzPython was invoked with -Sc                     \         P                  R ,          s\        P                  '       d   \
        P                  P                  \        P                  4      '       gL    \
        P                  ! \        P                  4       \        P                  ! \        P                  4       R# R# R#   \         d2   p \        P                  ! R\        P                  : RT : 24      hRp ? ii ; i)NNNz&unable to create user site directory (z): N)syspathOLD_SYS_PATHsiteENABLE_USER_SITEosisdir	USER_SITEmakedirs
addsitedirPermissionErrorunittestSkipTest)excs    %/usr/lib/python3.14/test/test_site.pysetUpModuler   .   s    88A;LRWW]]4>>%B%B	=KK'OODNN+ &C  	=##'+~~s%< = =	=s   "AB0 0C,;,C''C,c                  4    \         \        P                  R &   R# )r   N)r   r   r        r   tearDownModuler!   =   s    CHHQKr    c                   |  a  ] tR t^At o RtR tR tR tR tR t	R t
R]3R	 ltR
 tR tR tR tR tR t]P(                  ! ]! ]R4      R4      R 4       t]P(                  ! ]P2                  R8H  R4      ]P6                  ! 4       R 4       4       tR t]P(                  ! ]R4      R 4       t]P(                  ! ] PB                  R4      ]P6                  ! 4       R 4       4       t"]P(                  ! ]R4      R 4       t#]P(                  ! ]R4      R 4       t$R t%]P(                  ! ]R4      R 4       t&R t'R  t(R!t)V t*R"# )#HelperFunctionsTestsz Tests for helper functions.
    c                "   \         P                  R,          V n        \        P                  V n        \        P                  V n        \        P                  V n	        \        P                  V n        \        \        P                  4      V n        R# )zSave a copy of sys.pathr   N)r   r   sys_pathr   	USER_BASEold_baser   old_sitePREFIXESold_prefixes	sysconfig_CONFIG_VARSoriginal_varsr   old_varsselfs   &r   setUpHelperFunctionsTests.setUpE   sS     MM&33Y334r    c                   V P                   \        P                  R&   V P                  \        n        V P                  \        n        V P                  \        n	        V P                  \        n        \        P                  eJ   \        P                  P                  4        \        P                  P                  V P                  4       R# R# zRestore sys.pathr   N)r%   r   r   r'   r   r&   r(   r   r*   r)   r-   r+   r,   clearupdater.   r/   s   &r   tearDownHelperFunctionsTests.tearDownN   s    mm))!%!3!3	!!-""((*""))$--8 .r    c                   Rp\         P                  P                  ! V!  p\        P                  ! V!  w  r4V P                  \         P                  P                  V4      V4       V\         P                  P                  V4      8X  d   V P                  W44       R# V P                  \         P                  P                  V4      V4       R# )	BeginningN)r:   End)r   r   joinr   makepathassertEqualabspathnormcase)r0   
path_partsoriginal_dirabs_dirnorm_dirs   &    r   test_makepath"HelperFunctionsTests.test_makepathZ   s     *
ww||Z0 MM:66@277++L99W/RWW--g6Ar    c                R   \         P                  ! 4       p\        P                   Uu. uFQ  pV'       g   K  \        P                  P                  V4      '       g   K4  \         P                  ! V4      ^,          NKS  	  up F  pV P                  W1V: RV: 24       K  	  R# u upi )   z> from sys.path not found in set returned by _init_pathinfo(): N)r   _init_pathinfor   r   r   existsr=   assertIn)r0   dir_setr   entrys   &   r   test_init_pathinfo'HelperFunctionsTests.test_init_pathinfog   s~    %%'9< : -$&GGNN4$8 -dmmD)!,, :EMM%7<gGH: :s   
B$"B$!B$c                x   V P                  VP                  \        P                  RVP                  ,          4       V P                  \        P
                  ! VP                  4      ^ ,          \        P                  4       V P                  \        P                  P                  VP                  4      4       R# )z>Contain common code for testing results of reading a .pth filez%s not in sys.modulesN)rK   importedr   modulesr   r=   good_dir_pathr   assertFalser   rJ   bad_dir_pathr0   pth_files   &&r   pth_file_tests#HelperFunctionsTests.pth_file_testso   sr    h''-0A0AA	CdmmH$:$:;A>I(=(=>?r    c                4   \        4       pVP                  R R7        VP                  4        \        P                  ! VP
                  VP                  \        4       4       V P                  V4       VP                  4        R#   TP                  4        i ; iTprepN)	PthFilecleanupcreater   
addpackagebase_dirfilenamesetrX   rV   s   & r   test_addpackage$HelperFunctionsTests.test_addpackagev   sp    
 9d#	OOOOH--x/@/@#%H)Hs   AB B.c                L  a \         P                  P                  V4      pVR ,           p\         P                  P                  W$4      o\	        SRRR7      ;_uu_ 4       pV P                  V3R l4       VP                  V4       RRR4       W$3#   + '       g   i     Y$3# ; i).pthwutf-8encodingc                  0   < \         P                  ! S 4      # N)r   remove)pth_fns   r   <lambda>/HelperFunctionsTests.make_pth.<locals>.<lambda>   s    BIIf$5r    N)r   r   r?   r<   open
addCleanupwrite)r0   contentspth_dirpth_namepth_basenamerW   rq   s   &&&&  @r   make_pthHelperFunctionsTests.make_pth   s    ''//'*&(g4&#00HOO56NN8$ 1 $$ 10 $$s   'BB#	c           	     h   V P                  R 4      w  r\        4       ;_uu_ 4       p\        P                  ! W\	        4       4       RRR4       V P                  XP                  4       R4       V P                  VP                  4       \        P                  ! \        P                  P                  W4      4      4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  4       R4       R#   + '       g   i     L; i)zimport bad-syntax
Nzline 1	Tracebackzimport bad-syntaxSyntaxErrorr{   r   r   ra   rd   assertRegexgetvaluereescaper   r   r<   r0   rx   rq   err_outs   &   r   !test_addpackage_import_bad_syntax6HelperFunctionsTests.test_addpackage_import_bad_syntax   s    --(=>'OOGSU3 ))+X6))+IIbggll734	6
 	))+[9))+-AB))+]; s    D!!D1	c           	     (   V P                  R 4      w  r\        4       ;_uu_ 4       p\        P                  ! W\	        4       4       RRR4       V P                  XP                  4       R4       V P                  VP                  4       \        P                  ! \        P                  P                  W4      4      4       V P                  VP                  4       R4       V P                  VP                  4       R4       R#   + '       g   i     L; i)zrandompath
import nosuchmodule
Nzline 2r~   ModuleNotFoundErrorr   r   s   &   r   test_addpackage_import_bad_exec4HelperFunctionsTests.test_addpackage_import_bad_exec   s    --(KL'OOGSU3 ))+X6))+IIbggll734	6 	))+[9))+-BC s    DD	c                    V P                  R 4      w  r\        P                  ! W\        4       4      pV P	                  V\        4       4       R# )z

  

N)r{   r   ra   rd   r>   )r0   rx   rq   known_pathss   &   r   test_addpackage_empty_lines0HelperFunctionsTests.test_addpackage_empty_lines   s6    --5oogsu=ce,r    c           
        V P                  R 4      w  r\        4       ;_uu_ 4       pV P                  \        P                  ! W\        4       4      4       RRR4       RV n        V P                  XP                  4       R4       \        P                   F-  p\        V\        4      '       g   K  V P                  RV4       K/  	  R#   + '       g   i     Lz; i)zabc def
N zabc def)r{   r   rT   r   ra   rd   maxDiffr>   r   r   r   
isinstancestrassertNotIn)r0   rx   rq   r   r   s   &    r   #test_addpackage_import_bad_pth_file8HelperFunctionsTests.test_addpackage_import_bad_pth_file   s    --7'T__WceDE ))+R0HHD$$$  t4 	 s   /CC	c                   \        4       pVP                  R R7        VP                  4        \        P                  ! VP
                  \        4       4       V P                  V4       VP                  4        R#   TP                  4        i ; ir[   )r^   r_   r`   r   r   rb   rd   rX   rV   s   & r   test_addsitedir$HelperFunctionsTests.test_addsitedir   sh     9d#	OOOOH--su5)Hs   A
A: :Bc                   \        R 4      pVP                  RR7        VP                  4        \        P                  ! VP
                  \        4       4       V P                  \        P                  ! VP                  4      ^ ,          \        P                  4       V P                  VP
                  \        P                  4       VP                  4        R#   TP                  4        i ; i)z.dotfileTr\   N)r^   r_   r`   r   r   rb   rd   r   r=   rS   r   r   rK   rV   s   & r   test_addsitedir_dotfile,HelperFunctionsTests.test_addsitedir_dotfile   s    :&d#	OOOOH--su5T]]8+A+AB1EsxxPMM(++SXX6Hs   B(C C+chflagsztest needs os.chflags()c                   \        4       pVP                  R R7        VP                  4        \        P                  ! VP
                  4      p\        P                  ! VP
                  VP                  \        P                  ,          4       \        P                  ! VP                  \        4       4       V P                  \        P                  ! VP                  4      ^ ,          \         P"                  4       V P%                  VP                  \         P"                  4       VP                  4        R#   TP                  4        i ; ir[   )r^   r_   r`   r   stat	file_pathr   st_flags	UF_HIDDENr   r   rb   rd   r   r=   rS   r   r   rK   )r0   rW   sts   &  r   test_addsitedir_hidden_flags1HelperFunctionsTests.test_addsitedir_hidden_flags   s    9d#	OO++,BJJx))2;;+GHOOH--su5T]]8+A+AB1EsxxPMM(++SXX6Hs   DD8 8E
win32ztest needs Windowsc                    \        4       pVP                  R R7        VP                  4        \        P                  ! RRVP
                  .4       \        P                  ! VP                  \        4       4       V P                  \        P                  ! VP                  4      ^ ,          \        P                  4       V P                  VP                  \        P                  4       VP                  4        R#   TP                  4        i ; i)Tr\   attribz+HN)r^   r_   r`   
subprocess
check_callr   r   r   rb   rd   r   r=   rS   r   r   rK   rV   s   & r   %test_addsitedir_hidden_file_attribute:HelperFunctionsTests.test_addsitedir_hidden_file_attribute   s     9d#	OO!!8T83E3E"FGOOH--su5T]]8+A+AB1EsxxPMM(++SXX6Hs   CC; ;Dc                v    V P                  \        P                  ! 4       \        P                  ! 4       4       R # ro   )r>   r   _getuserbaser+   r/   s   &r   test__getuserbase&HelperFunctionsTests.test__getuserbase   s$    **,i.D.D.FGr    zneed user sitec                f   \         P                  R 8X  d   \         P                  '       d   RpM\        P                  R,           pV P                  \        P                  P                  \        P                  ! \        P                  ! 4       4      4      \        P                  ! RV4      4       R# )darwinosx_framework_user_userpurelibN)r   platform
_frameworkr   namer>   r   normpathr   	_get_pathr   r+   get_path)r0   schemes   & r   test_get_path"HelperFunctionsTests.test_get_path   sk    <<8#)FWWw&F))$..9J9J9L*MN"++Iv>	@r    z<requires access to PEP 370 user-site (site.ENABLE_USER_SITE)c                ~   \         P                  P                  \        P                  4      pV P                  V\        P                  4       \         P                  P                  4       p\        P                  ! \        P                  R RV,          .VR7      pV P                  V^4       \         P                  P                  4       p\        P                  ! \        P                  RR RV,          .VR7      pV\        P                  ! 4       ^ ,          8X  d   V P                  V^4       MV P                  V^ R4       \         P                  P                  4       pRVR&   \        P                  ! \        P                  R RV,          .VR7      pV\        P                  ! 4       ^ ,          8X  d   V P                  V^4       MV P                  V^ R4       \         P                  P                  4       pRVR	&   \        P                  ! \        P                  R R
.VR7      pV P                  V^R4       R# )-cz$import sys; sys.exit(%r in sys.path)env-sz%User site still added to path with -s1PYTHONNOUSERSITEz3User site still added to path with PYTHONNOUSERSITEz/tmpPYTHONUSERBASEz=import sys, site; sys.exit(site.USER_BASE.startswith("/tmp"))z#User base not set by PYTHONUSERBASEN)r   r   r   r   r   rK   r   environr   r   call
executabler>   getsitepackages)r0   usersiter   rcs   &   r   test_s_option"HelperFunctionsTests.test_s_option   s   
 77##DNN3h)jjoo__cnnd2X=? 	Qjjoo__cnndD2X=? t++-a00R#R$KLjjoo"%__cnnd2X=? t++-a00R#RMO jjoo &__cnndKM 	Q=	?r    c                d   R \         n        \         P                  ! 4       pV P                  \         P                  V4       R \         n        ^ R IpR Vn        \        4       ;_uu_ 4       pRVR&   V P                  \         P                  ! 4       R4       R R R 4       R #   + '       g   i     R # ; i)Nxoxor   )r   r&   getuserbaser>   r+   r,   r	   assertStartsWith)r0   	user_baser+   r   s   &   r   test_getuserbase%HelperFunctionsTests.test_getuserbase'  s    $$&	 	3 !%	 ""g(.G$%!!$"2"2"4f= #"""s   )+BB/	c                B   R \         n        R \         n        \         P                  ! 4       pV P	                  \         P                  V4       V P                  V\         P                  4       V P	                  \         P                  \         P                  ! 4       4       R # ro   )r   r   r&   getusersitepackagesr>   r   r   )r0   	user_sites   & r   test_getusersitepackages-HelperFunctionsTests.test_getusersitepackages8  se    ,,.	 	3i8)9)9);<r    c                   R .\         n        \         P                  ! 4       p\        P                  R8X  d   \
        P                  R8w  d|   V P                  \        V4      ^4       \        P                  P                  R \
        P                  R\        P                  ! 4        2R4      pV P                  V^ ,          V4       MV P                  \        V4      ^4       \        P                  P                  R RR\        P                  ! 4        2R4      pV P                  VR,          V4       R# V P                  \        V4      ^4       V P                  V^ ,          R 4       \        P                  P                  R RR4      pV P                  \        P                  P                  V^,          4      \        P                  P                  V4      4       R# )r   /libpythonzsite-packagesN)r   r)   r   r   sepr   
platlibdirr>   lenr   r<   r+   _get_python_version_abir@   )r0   dirswanteds   &  r   test_getsitepackages)HelperFunctionsTests.test_getsitepackagesC  sW   ##%66S=~~&  TA.fcnn(.y/P/P/R.S&T&57   a&1  TA.WW\\&%$*9+L+L+N*O"P"13F T"Xv. SY*T!Wf-WW\\&%AFRWW--d1g6WW--f57r    c                   R \         n        R \         n        \        4       ;_uu_ 4       p\        P
                  ! RR 4      ;_uu_ 4        VP                  RR4       \         P                  ! 4       pV P                  VR\        P                  ,           4       \         P                  ! 4       pV P                  W24       R R R 4       R R R 4       \        P
                  ! RRR7      ;_uu_ 4       p\        P
                  P                  \         R	4      ;_uu_ 4       p\        P                  ! \         R
R4      ;_uu_ 4        \        4       p\         P                   ! V4       VP#                  X4       VP%                  4        V P'                  V4       R R R 4       R R R 4       R R R 4       R #   + '       g   i     L; i  + '       g   i     EL; i  + '       g   i     LI; i  + '       g   i     LT; i  + '       g   i     R # ; i)Nzos.path.expanduserc                     V # ro   r   )r   s   &r   rr   =HelperFunctionsTests.test_no_home_directory.<locals>.<lambda>e  s    4r    r   APPDATA~zos.path.isdirF)return_valuer   r   T)r   r   r&   r	   r
   patchunsetr   r   r   r   r   objectr   	swap_attrrd   addusersitepackagesassert_called_once_withassert_not_calledrT   )r0   r   r   r   
mock_isdirmock_addsitedirr   s   &      r   test_no_home_directory+HelperFunctionsTests.test_no_home_directory\  sU   
  ""gZZ,.?@@MM*I6((*I!!)S266\:002I!!)7 A # ZZe<<
ZZt\22ot%7>> %K$$[1..y9--/[) ? 3 =< A@ #"" ?> 32 =<<sa   !G
A5F.	?G/-G;%G(	AGG(	G;.F>9GG	G% G(	(G83G;;H	c                    R p\        RRV R2VR7      w  r#pV P                  V^ 4       \        RRRV R2VR7      w  r#pV P                  V^ 4       R# )filer   z.import site; assert site.gethistoryfile() == "")PYTHON_HISTORY-Iz.import site; assert site.gethistoryfile() != "N)r   r>   )r0   rc   r   outerrs   &    r   test_gethistoryfile(HelperFunctionsTests.test_gethistoryfile{  sm    '<XJaH#% 	Q (d<XJaH#% 	Qr    c           
        R pRVR,           3R3 F  w  r#\         P                  ! R\         P                  ! VR7      4      ;_uu_ 4        \         P                  ! R\        P                  ! 4       4      ;_uu_ 4        \
        P                  ! V4       V P                  \        P                  P                  4       V4       RRR4       RRR4       K  	  R#   + '       g   i     L; i  + '       g   i     K  ; i)zbla-bla-blaT
z	sys.flags)verbosez
sys.stderrN)Fr   )r
   r   MockioStringIOr   _tracer>   r   stderrr   )r0   messager  r   s   &   r   
test_traceHelperFunctionsTests.test_trace  s    !7T>2K?LGK7)CDDJJ|R[[];;G$  !4!4!6< < ED @;; EDDs%   	3C*<ACC*C'"C**C;)r   r'   r*   r(   r.   r-   r%   N)+__name__
__module____qualname____firstlineno____doc__r1   r7   rE   rN   rX   re   r   r{   r   r   r   r   r   r   r   
skipUnlesshasattrr   r   r   r   r   requires_subprocessr   r   HAS_USER_SITEr   r   r   r   r   r   r   r   r  r  __static_attributes____classdictcell____classdict__s   @r   r#   r#   A   s    5
9BH@ *-v %<
D-	5	 Y/1JK L 02FG  "
 # H
H (89@ :@ .. 1> ?  "%? #?%?N (89> :>  (89= :=72 (89* :*< = =r    r#   c                   F   a  ] tR tRt o Rt]RRR3R ltR tRR ltR	t	V t
R
# )r^   i  z/Helper class for handling testing of .pth filestime__testdir____badc                   VR,           V n         \        P                  P                  R4      V n        \        P                  P                  V P                  V P                   4      V n        W n        W0n        W@n	        \        P                  P                  V P                  V P                  4      V n
        \        P                  P                  V P                  V P                  4      V n        R# )zInitialize instance variablesri   r   N)rc   r   r   r?   rb   r<   r   rQ   good_dirnamebad_dirnamerS   rU   )r0   filename_baserQ   r!  r"  s   &&&&&r   __init__PthFile.__init__  s     &.+dmmT]]C (&WW\\$--9J9JKGGLL8H8HIr    c                   \        V P                  R4      p \        RVR7       \        RVR7       \        RV P                  ,          VR7       \        V P                  VR7       \        V P
                  VR7       VP                  4        \        P                  ! V P                  4       R#   TP                  4        i ; i)a?  Create a .pth file with a comment, blank lines, an ``import
<self.imported>``, a line with self.good_dirname, and a line with
self.bad_dirname.

Creation of the directory for self.good_dir_path (based off of
self.good_dirname) is also performed.

Make sure to call self.cleanup() to undo anything done by this method.

rj   z#import @bad module namer   r  z	import %sN)
rt   r   printrQ   r!  r"  closer   mkdirrS   )r0   FILEs   & r   r`   PthFile.create  s     DNNC(	,48$T"+-D9$##$/$"".JJL
##$ JJLs   A&B0 0Cc                   \         P                  P                  V P                  4      '       d!   \         P                  ! V P                  4       V'       d]   \
        P                  P                  V P                  4      V n	        V P                  '       d   \
        P                  V P                   M9V P                  '       d(   V P                  \
        P                  V P                  &   \         P                  P                  V P                  4      '       d!   \         P                  ! V P                  4       \         P                  P                  V P                  4      '       d#   \         P                  ! V P                  4       R# R# )zMake sure that the .pth file is deleted, self.imported is not in
sys.modules, and that both self.good_dirname and self.bad_dirname are
not existing directories.N)r   r   rJ   r   rp   r   rR   getrQ   imported_modulerS   rmdirrU   )r0   r]   s   &&r   r_   PthFile.cleanup  s     77>>$..))IIdnn%#&;;??4==#AD ###KK.###-1-A-ADMM*77>>$,,--HHT''(77>>$++,,HHT&&' -r    )	rU   r"  rb   r   rc   rS   r!  rQ   r/  N)F)r  r  r  r  r  r   r$  r`   r_   r  r  r  s   @r   r^   r^     s'     9%+f!.G
J%,( (r    r^   c                     a  ] tR tRt o RtR tR tR tR t]	P                  ! R4      R 4       tR	 tR
 tR tR t]P"                  ! 4       R 4       t]	P&                  ! ]! ]P,                  R4      R4      ]P                   P1                  R4      ]P                   P2                  R 4       4       4       t]P6                  R 4       tRtV tR# )ImportSideEffectTestsi  z(Test side-effects from importing 'site'.c                >    \         P                  R,          V n        R# )zMake a copy of sys.pathr   N)r   r   r%   r/   s   &r   r1   ImportSideEffectTests.setUp  s    r    c                @    V P                   \        P                  R&   R# r4   )r%   r   r   r/   s   &r   r7   ImportSideEffectTests.tearDown  s    mmr    c                    R\         P                  R,          n        \        P                  ! 4        V P                  \         P                  R,          P                  4       R# )z{Test for __cached__ is None.

Regarding to PEP 3147, __cached__ can be None.

See also: https://bugs.python.org/issue30167
Ntest)r   rR   
__cached__r   	abs_pathsassertIsNoner/   s   &r   test_abs_paths_cached_None0ImportSideEffectTests.test_abs_paths_cached_None  s<     *.F&#++f-889r    c                    \         P                  ! 4        \        4       p\        P                   F%  pV P                  W!4       VP                  V4       K'  	  R # ro   )r   removeduppathsrd   r   r   r   add)r0   
seen_pathsr   s   &  r   test_no_duplicate_paths-ImportSideEffectTests.test_no_duplicate_paths  s?     	U
HHDT.NN4  r    ztest not implementedc                    R # ro   r   r/   s   &r   test_add_build_dir(ImportSideEffectTests.test_add_build_dir  s    
 	r    c                ^    V P                  \        R 4       V P                  \        R4       R# )quitexitNassertHasAttrbuiltinsr/   s   &r   test_setting_quit'ImportSideEffectTests.test_setting_quit  s"    8V,8V,r    c                    V P                  \        R 4       V P                  \        R4       V P                  \        R4       R# )	copyrightcreditslicenseNrK  r/   s   &r   test_setting_copyright,ImportSideEffectTests.test_setting_copyright  s2    8[18Y/8Y/r    c                2    V P                  \        R 4       R# )helpNrK  r/   s   &r   test_setting_help'ImportSideEffectTests.test_setting_help  s    8V,r    c                    R \         P                  9  d    ^ RIpV P                  R4       R# R#   \         d     R# i ; i)sitecustomizeNz(sitecustomize not imported automatically)r   rR   r[  failImportError)r0   r[  s   & r   test_sitecustomize_executed1ImportSideEffectTests.test_sitecustomize_executed  s?    #++-F$ 		DE .  s   0 ??c           
     4   R .p\         P                  '       d   VP                  R4       \        P                  ! 4       pV P                  \        P                  V4       \        4       ;_uu_ 4       pW#R&   V EFj  p\        P                  ! V4       \        P                  ! V4       \        P                  P                  W$ R24      pRV 2p\        VR4      ;_uu_ 4       pVP                  RV R24       RRR4       \        P                   ! \"        P$                  R	R
.4      pV P'                  WhP)                  R4      4       \        P                   ! \"        P$                  RR	R
.4      pV P+                  WhP)                  R4      4       RV8X  g   EK"  \        P                   ! \"        P$                  RR	R
.4      pV P+                  WhP)                  R4      4       EKm  	  RRR4       R#   + '       g   i     EL; i  + '       g   i     R# ; i)r[  usercustomize
PYTHONPATHz.py	EXECUTED_rj   zprint("z")Nr   z""rk   z-Sr   )r   r   appendtempfilemkdtempru   r   rmtreer	   r   r*  r   r<   rt   rv   r   check_outputr   r   rK   decoder   )	r0   	mod_namestemp_dirr   module_namecustomize_path
eyecatcherfoutputs	   &        r   %test_customization_modules_on_startup;ImportSideEffectTests.test_customization_modules_on_startup  s    
	    _-##%	(((3 ""g$,L!(  *"!#h-s8K!L(6
.#..!GGgj\45 / $00#..$1MNj--*@A $00#..$d1ST  ]]7-CD #k1'44cnndDRV5WXF$$Zw1GH)  ) #" /.. #""s-   2A2H$G2:BHAH2H=	HH	HTTPSHandlerz$need SSL support to download licensenetworkc           	        \         P                  P                  4       ^,          p\        P                  P                  VRR7      pV P                  \        P                  P                  4        \        P                  ! V4      ;_uu_ 4        \        P                  P                  V4      ;_uu_ 4       pVP                  4       pRRR4       RRR4       T P                  X^RT,           R7       R#   + '       g   i     L5; i  + '       g   i     L@; i  \        P                  P                   d   pTP                  p Rp?LsRp?ii ; i)rH   HEAD)methodNzCan't find )msg)rS  _Printer__dataspliturllibrequestRequestru   
urlcleanupr   transient_interneturlopengetcodeerror	HTTPErrorcoder>   )r0   urlreqdatar  es   &     r   test_license_exists_at_url0ImportSideEffectTests.test_license_exists_at_url-  s     $$**,Q/nn$$S$8112	11#66^^++C00D<<>D 1 7
 	s(;<	 10 76 ||%% 	66D	sN   1D (D7C5	DD 5D DD	D D E:EEc                8    \         P                  ! R . RO4       R# )r   N)r  locale	tracebackatexitwarningstextwrap)r   ensure_lazy_importsr/   s   &r   test_lazy_imports'ImportSideEffectTests.test_lazy_imports@  s    ))& 3
 	r    )r%   N)r  r  r  r  r  r1   r7   r=  rC  r   skiprF  rN  rT  rX  r^  r   r  rq  r  r  r{  r|  r9  requires_resourcesystem_must_validate_certr  cpython_onlyr  r  r  r  s   @r   r3  r3    s     2$$	:! ]])* +-
0-F   ""I #"IJ @?A	\\##I.	\\++= , /A=  r    r3  c                      a  ] tR tRt o ]P
                  ! 4       R 4       t]P
                  ! 4       R 4       t]P
                  ! 4       R 4       t]P
                  ! 4       R 4       t	Rt
V tR# )StartupImportTestsiL  c           	     x   \         P                  ! \        P                  R RRRR.\         P                  RRR7      pVP                  4       ^ ,          pV P                  VP                  ^ \        V4      4       \        P                  ! V4      pV Fu  p\        P                  ! \        P                  P                  \        P                  ! V4      R4      4      pV'       g   KU  V P!                  R	\#        V4       R
V 24       Kw  	  \         P                  ! \        P                  R RRRRR.\         P                  \         P                  RRR7      pVP                  4       w  r&V P                  VP                  ^ W&34       \        P                  ! V4      pV P%                  RV4       0 RmpV P'                  VP)                  V4      V4       V P+                  RWv4       V P+                  RWv4       0 RmP-                  \        P.                  4      p	V P'                  VP)                  V	4      V4       R# )-Xutf8r   r   z!import sys; print(repr(sys.path))rk   surrogateescape)stdoutrm   errorsz*.pthzfound z .pth files in: z-vz#import sys; print(set(sys.modules)))r  r  rm   r  r   r  copyregN>   r   _sre
re._parserre._compilerre._constants>
   heapqtypeskeywordreprlibweakrefoperator	functools	itertoolscollections_collections)r   Popenr   r   PIPEcommunicater>   
returncodereprastliteral_evalglobr   r   r<   r   skipTestr   rK   rT   intersectionr   
differencebuiltin_module_names)
r0   popenr  isolated_pathsr   	pth_filesr  rR   re_modscollection_modss
   &         r   test_startup_imports'StartupImportTests.test_startup_importsN  s      #..$"&(K"M(2*1(9	;
 ""$Q'))1d6l;))&1
 #D		"'',,t{{4/@'"JKIys9~&66FtfMN #   #..$d"&(M"O(2(2*1(9; **,))1v.>?""6*fg& P--g6? 	73 	G4 'Js'?'?@ 	 	--o>Gr    c                    \         P                  ! \        P                  R R.4      P	                  4       pV P                  VR4       R# )r   9import sys; sys.exit(hasattr(sys, "__interactivehook__"))z''__interactivehook__' not added by siteNr   r  r   r   wait
assertTruer0   rs   & r   test_startup_interactivehook/StartupImportTests.test_startup_interactivehook  s=    cnndGI JJN$& 	
DEr    c                    \         P                  ! \        P                  R RR.4      P	                  4       pV P                  VR4       R# )r   r   r  z,'__interactivehook__' added in isolated modeN)r   r  r   r   r  rT   r  s   & r   %test_startup_interactivehook_isolated8StartupImportTests.test_startup_interactivehook_isolated  sC     cnndDGI JJN$& 	
JKr    c                    \         P                  ! \        P                  R RR.4      P	                  4       pV P                  VR4       R# )r   r   zYimport site, sys; site.enablerlcompleter(); sys.exit(hasattr(sys, "__interactivehook__"))z6'__interactivehook__' not added by enablerlcompleter()Nr  r  s   & r   .test_startup_interactivehook_isolated_explicitAStartupImportTests.test_startup_interactivehook_isolated_explicit  sC     cnndDgi jjnjnjp 	
STr    r   N)r  r  r  r  r   r  r  r  r  r  r  r  r  s   @r   r  r  L  s       "0H #0Hd   "F #F
   "L #L   "U #Ur    r  c                   (  a  ] tR tRt o ]P
                  R8X  d   RR ltMRR ltR tV 3R lR lt]	P                  ! 4       R 4       t]	P                  ! 4       R	 4       t]	P                  ! 4       R
 4       t]	P                  ! 4       R 4       tRtV tR# )_pthFileTestsi  r   c           
        ^ RI p\        P                  ! 4       pV P                  \        P
                  V4       \        P                  P                  V\        P                  P                  \        P                  4      ^,          4      pVP                  \        P                  4      p\        P                  P                  V\        P                  P                  V4      ^,          4      p\        P                  ! \        P                  V4       \        P                  ! Wg4       \         P                   ! \        P                  P                  \        P                  P                  V4      ^ ,          R4      4       F\  p\        P                  ! V\        P                  P                  V\        P                  P                  V4      ^,          4      4       K^  	  V'       d/   \        P                  P#                  V4      ^ ,          R,           p	M-\        P                  P#                  V4      ^ ,          R,           p	\%        V	RRR7      ;_uu_ 4       p
V F  p\'        WR7       K  	  RRR4       V#   + '       g   i     T# ; i)    Nzvcruntime*.dll._pthrj   r  rl   r'  )_winapire  rf  ru   r   rg  r   r   r<   rz  r   r   GetModuleFileName	dllhandleshutilr   r  splitextrt   r(  )r0   linesexe_pthr  rk  exe_filedll_src_filedll_filefn	_pth_filero  lines   &&&         r   _create_underpth_exe"_pthFileTests._create_underpth_exe  s   '')HOOI,,h7ww||HbggmmCNN.KA.NOH"44S]]CLww||HbggmmL.I!.LMHKK1KK/iiRWW]]<-H-KM] ^_BXrww}}R7H7K LM `GG,,X6q9GC	GG,,X6q9GC	iv66!!D$' " 7 O 76 Os   I;;J	c                8   V'       g   \         P                  ! R 4      h\        P                  ! 4       pV P	                  \
        P                  V4       \        P                  P                  V\        P                  P                  \        P                  4      ^,          4      p\        P                  ! \        P                  V4       VR,           p\        VR4      ;_uu_ 4       pV F  p\        WvR7       K  	  RRR4       V#   + '       g   i     T# ; i)z1library ._pth file not supported on this platformr  rj   r'  N)r   r   re  rf  ru   r   rg  r   r   r<   rz  r   r   symlinkrt   r(  )r0   r  r  rk  r  r  ro  r  s   &&&     r   r  r    s    ''([\\'')HOOI,,h7ww||HbggmmCNN.KA.NOHJJs~~x0 7*Ii%%!D$' " & O &% Os   (DD	c                    . pV Fh  pV'       d   V^ ,          R8X  d   K  \         P                  P                  \         P                  P                  W4      4      pVP	                  V4       Kj  	  V# )r  #)r   r   r?   r<   rd  )r0   
sys_prefixr  r%   r  abs_paths   &&&   r   "_calc_sys_path_for_underpth_nosite0_pthFileTests._calc_sys_path_for_underpth_nosite  sS    D47c>wwrww||J'EFHOOH%	 
 r    c                &   < V ^8  d   QhRS[ RS[/# )   libpathimport_site)r   bool)formatr  s   "r   __annotate___pthFileTests.__annotate__  s      c 4 r    c               B  a R .p\        SP                  R4      4      p\        ^RV,          4      pV^8:  d   V P                  RVR R24       VP	                  V3R l\        V4       4       4       VP	                  RR.4       V'       d   VP                  R	4       V# )
fake-path-namerk   i0u  z Python stdlib path is too long (,z bytes)c              3   (   <"   T F  pSx  K	  	  R # 5iro   r   ).0_r  s   & r   	<genexpr>/_pthFileTests._get_pth_lines.<locals>.<genexpr>  s     =*<Q*<s   r   z	# commentzimport site)r   encodeminr  extendrangerd  )r0   r  r  	pth_linesencoded_libpath_lengthrepetitionss   &f$   r   _get_pth_lines_pthFileTests._get_pth_lines  s    %&	 "%W^^G%<!=#u(>>?!MM23I!2LGTV=%*<=="k*+]+r    c                z   R R.\         P                  ORNRNpV P                  V4      pV P                  \        P                  P                  V4      V4      p\        P                  ! VRRRR.RR	R
7      pVP                  4       P                  R4      pV P                  VR4       V P                  VVR4       R# )z#.z# ..rg   z..r  r  r   Cimport sys; print("\n".join(sys.path) if sys.flags.no_site else "")rk   r  )rm   r  r  sys.flags.no_site was Falsesys.path is incorrectN)r   r   r  r  r   dirnamer   rh  rstriprz  r  r>   )r0   r  r  r%   rp  actual_sys_paths   &     r   test_underpth_basic!_pthFileTests.test_underpth_basic  s    68CHH8c848	,,Y7::GGOOH% (((D&$R*
$57 !--///5)FG#	
r    c                   \         P                  P                  p\        P                  P                  \        P                  4      pV P                  VR R7      pV P                  V4      pV P                  \        P                  P                  V4      V4      p\        P                  P                  4       pRVR&   RP                  V\        P                  \        P                  ! R4      4      VR&   \         P"                  ! VRR.VRR	R
7      pVP%                  4       P'                  R4      pV P)                  VR4       V P+                  VVR4       R# )Fr  from-envrb  z{}{}{}PATHr   r  rk   r  )r   rm   r  r  r  r	  N)r9  r   
STDLIB_DIRr   r   r
  r   r   r  r  r  r   r   r  pathsepgetenvr   rh  r  rz  r  r>   )	r0   r  
exe_prefixr  r  r%   r   rp  r  s	   &        r   test_underpth_nosite_file'_pthFileTests.test_underpth_nosite_file  s   ,,))WW__S^^4
''U'C	,,Y7::GGOOH% jjoo&Looj"**bii>OPF(((DR*
W->@ !--///5)FG#	
r    c                   \         P                  P                  p\        P                  P                  \        P                  4      pV P                  V P                  VR R7      4      p\        P                  P                  V4      p\        P                  P                  4       pRVR&   RP                  V\        P                  ! R4      4      VR&   \        P                  ! VRR\        P                  P!                  VR4      : R	V: R	\        P                  P!                  VR4      : R
2.VR7      pV P#                  VR4       R# )Tr  r  rb  {};{}r  r   /import sys; sys.exit(not sys.flags.no_site and r   in sys.path and L not in sys.path and all("\r" not in p and "\n" not in p for p in sys.path))r   r	  Nr9  r   r  r   r   r
  r   r   r  r  r   r   r  r  r   r   r<   r  r0   r  r  r  r  r   r   s   &      r   test_underpth_file _pthFileTests.test_underpth_file  s    ,,))WW__S^^4
,,T:<WW__X.
jjoo&LnnZ61BCF__h Z)9:Z4  	34r    c                   \         P                  P                  p\        P                  P                  \        P                  4      pV P                  V P                  VR R7      RR7      p\        P                  P                  V4      p\        P                  P                  4       pRVR&   RP                  V\        P                  ! R4      4      VR&   \        P                  ! VRR	\        P                  P!                  VR
4      : RV: R\        P                  P!                  VR4      : R2.VR7      pV P#                  VR4       R# )Tr  F)r  r  rb  r  r  r   r  r  r  r  r   r	  Nr  r  s   &      r   test_underpth_dll_file$_pthFileTests.test_underpth_dll_file  s    ,,))WW__S^^4
,,T:E - KWW__X.
jjoo&LnnZ61BCF__h Z)9:Z4  	34r    r   N)T)r  r  r  r  r   r   r  r  r  r   r  r  r  r   r#  r  r  r  s   @r   r  r    s     
||w	(	     "
 #
$   "
 #
.   "5 #5&   "5 #5r    r  __main__)1r  r   test.supportr9  r   test.support.script_helperr   r   r   r   r   test.support.os_helperr   r	   r  rM  r  r  r   r   r  r   r   r   r+   re  urllib.errorr{  urllib.requestr
   r   flagsno_siter   r   r   r  r   r   r!   TestCaser#   r   r^   r3  r  r  r  mainr   r    r   <module>r/     s      7 & " & ( > 
   	 	 	    
      
 99


8
99  t+=M=8,, M=`
5(f 5(nAH-- AHGU** GURN5H%% N5b zMMO r    