+
    Big                        ^ 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HtHtHtHtHt ^ RIHtHtHt ^ RIHtHtHt ^ RIH t H!t! ^ RI"t"^ RI"H#t#H$t$H%t%H&t& Rt'RRR	RR
RRRRRRR/t(R]R]"RRR.R]PR                  ^ ,          RRRRR]*! ](^RRR7      /t+]+PY                  ](4        ! R R4      t- ! R R]P\                  ]-4      t/ ! R R]P\                  ]-4      t0 ! R  R!]P\                  ]-4      t1] ! R" R#]P\                  4      4       t2]3R$8X  d   ]Ph                  ! 4        R# R# )%    N)force_not_colorized_test_classinfinite_recursion
no_tracingrequires_resourcerequires_subprocessverbose)forgetmake_legacy_pycunload)create_empty_filetemp_dirFakePath)make_scriptmake_zip_script)	_run_code_run_module_code
run_modulerun_patha  # Check basic code execution
result = ['Top level assignment']
def f():
    result.append('Lower level reference')
f()
del f
# Check the sys module
import sys
run_argv0 = sys.argv[0]
run_name_in_sys_modules = __name__ in sys.modules
module_in_sys_modules = (run_name_in_sys_modules and
                         globals() is sys.modules[__name__].__dict__)
# Check nested operation
import runpy
nested = runpy._run_module_code('x=1\n', mod_name='<run>')
__name____file__
__cached____package____doc____spec__sysrunpyresultzTop level assignmentzLower level reference	run_argv0run_name_in_sys_modulesFmodule_in_sys_modulesnestedz<run>)xr   
__loader__c                   4   a  ] tR t^Kt o . ROtR tR tRtV tR# )CodeExecutionMixinc                x   VP                  4       pVP                  4       p\        V4       Fs  pVP                  R4      '       g   K  VP                  R4      '       g   K5  W29  d   VP	                  V4       W2R,          9  g   K[  VR,          P	                  V4       Ku  	  VP	                  R4      pVP	                  R4      pVf   V P                  V4       MVP                  e9   V P                  \        VP                  4      \        VP                  4      4       V P                   F7  pRV,           pV\        WF4      3pV\        WV4      3pV P                  Wx4       K9  	  V P                  \        V4      \        V4      4       V F(  pW1V,          3pW2V,          3pV P                  Wx4       K*  	  R# )zOCheck two namespaces match.

Ignores any unspecified interpreter created names
__r!   r   Nz	__spec__.)copylist
startswithendswithpopassertIsNoneloaderassertEqualtypeCHECKED_SPEC_ATTRIBUTESgetattrset)	self	result_nsexpected_nskresult_specexpected_specattractualexpecteds	   &&&      &/usr/lib/python3.14/test/test_runpy.pyassertNamespaceMatches)CodeExecutionMixin.assertNamespaceMatchesW   ss    NN$	!&&(iA||D!!ajj&6&6'MM!$11h'++A. !  mmJ/#
3 k* ##/  k&8&8!9!%m&:&:!;=44$&W[78w};<  2	 5 	Y[)9:A1&Fq>*HV.     c                   \        4       pVP                  4       pVR,          p\        P                  ^ ,          p\        P                  P                  WS4      pV! R4      pV P                  W4       V P                  \        P                  ^ ,          V4       V P                  \        P                  P                  WS4      V4       RV/p	W4R&   V! V	4      pV P                  W4       V P                  W4       V P                  \        P                  ^ ,          V4       V P                  \        P                  P                  WS4      V4       R# )zCheck that an interface runs the example code correctly

First argument is a callable accepting the initial globals and
using them to create the actual namespace
Second argument is the expected result
r   Nsentinel)	objectr(   r   argvmodulesgetr>   assertIsassertIsNot)
r4   create_namespaceexpected_namespacerB   r6   run_namesaved_argv0	saved_modr5   
initial_nss
   &&&       r=   check_code_execution'CodeExecutionMixin.check_code_execution   s     8(--/z*hhqkKKOOH7	$T*	##I;chhqk;/ckkooh99E (+
"*J$Z0	/##I;chhqk;/ckkooh99Er@    N)nameparentorigincachedhas_locationsubmodule_search_locations)	r   
__module____qualname____firstlineno__r1   r>   rO   __static_attributes____classdictcell____classdict__s   @r=   r%   r%   K   s      M&/PF Fr@   r%   c                   0   a  ] tR t^t o RtR tR tRtV tR# )ExecutionLayerTestCasez9Unit tests for runpy._run_code and runpy._run_module_codec                |    \         P                  4       pVP                  R R/4       R pV P                  W!4       R# )r#   Nc                 $    \        \        / V 4      # N)r   example_source)init_globalss   &r=   	create_ns7ExecutionLayerTestCase.test_run_code.<locals>.create_ns   s    ^R>>r@   )example_namespacer(   updaterO   )r4   r6   rf   s   &  r=   test_run_code$ExecutionLayerTestCase.test_run_code   s;    ',,.$
 		?!!)9r@   c                   aa R oRpRpRp\         P                  P                  SVVR7      o\        P	                  4       pVP                  RSRVRVRVR	SR
VRRRR/4       VV3R lpV P                  WT4       R# )z
<Nonsense>zSome other nonsensezNow you're just being silly )rT   r.   r   r   r#   r   r   r   r   Tr    c                 (   < \        \        V SS4      # rc   )r   rd   )re   mod_namemod_specs   &r=   rf   >ExecutionLayerTestCase.test_run_module_code.<locals>.create_ns   s    #N$0$,$,. .r@   N)	importlib	machinery
ModuleSpecrh   r(   ri   rO   )r4   	mod_fname
mod_loadermod_packager6   rf   ro   rp   s   &     @@r=   test_run_module_code+ExecutionLayerTestCase.test_run_module_code   s    )	2
&&11(9B9C 2 E (,,.	*;%t#T	
 			.
 	!!)9r@   rQ   N)	r   rX   rY   rZ   r   rj   rx   r[   r\   r]   s   @r=   r`   r`      s     C:: :r@   r`   c                      a  ] tR t^t o RtR tR tR tR!R ltR"RRRR/R	 llt	R
 t
R tR!RRRR/R lltR!RRRR/R lltR tR#R ltR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tV t R# )$RunModuleTestCasezUnit tests for runpy.run_modulec                r     \        V4       V P                  R V,           4       R#   \         d     R# i ; i)zExpected import error for N)r   failImportError)r4   ro   s   &&r=   expect_import_error%RunModuleTestCase.expect_import_error   s7    	?x  II2X=>  		s   ' 66c                8   V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R	# )
r   zsys.imp.ericzos.path.halfza.beez.howardz..eatenz.test_runpyz	.unittestmultiprocessingN)r   r4   s   &r=   test_invalid_names$RunModuleTestCase.test_invalid_names   s      '  0  0  )  +  +  /  -  !23r@   c                J    V P                  \        R 4      R,          R 4       R# )r   r   N)r/   r   r   s   &r=   test_library_module%RunModuleTestCase.test_library_module   s    G,Z8'Br@   Fc                    \         P                  ! V4       V'       d   R # \         P                  P                  VR4      p\	        V4       V# )N__init__.py)osmkdirpathjoinr   )r4   pkg_dir	namespace	pkg_fnames   &&& r=   _add_pkg_dirRunModuleTestCase._add_pkg_dir   s6    
GGLL-8	)$r@   r   parent_namespacesc                  V'       g	   V'       d   V'       g   \        R 4      hRpV\        P                  ,           R,           p\        P                  P	                  \
        P                  ! 4       4      ;r\        ^8  d   \        RV	4       \        P                  P                  ^ V4       \        ^8  d"   \        R\        P                  ^ ,          4       V'       dx   V.V,          p
WJR
&   V
 Fc  p\        P                  P                  W4      p	V P                  W4      p\        ^8  d   \        RV	4       \        ^8  g   KW  \        RV4       Ke  	  \        P                  P                  W4      p\        VR4      ;_uu_ 4       pVP                  V4       RRR4       \        ^8  d   \        RV4       VR	,           V,          V,           p\        P                   P#                  VV4      pWVV3#   + '       g   i     Lc; i)z2Can't mark top level module as a namespace package__runpy_pkg__pyz  Package tree in:z  Updated sys.path:z  Next level in:z
  Created:wN.)RuntimeErrorr   extsepr   realpathtempfilemkdtempr   printr   insertr   r   openwriterr   utilspec_from_file_location)r4   sourcedepthmod_baser   r   pkg_name
test_fnamer   sub_dirnamespace_flagsnamespace_flagr   ru   mod_filero   rp   s   &&&&$$           r=   	_make_pkgRunModuleTestCase._make_pkg   s~    *E  3 4 4"bii',
GG,,X-=-=-?@@Q;2G<7#Q;3SXXa[A01E9O"+B"1'',,w9 --gF	Q;&8' BQ;lI >	 #2
 GGLL5	)S!!XNN6" "Q;lI6SL%'(2>>99(:CE8X55 "!s   G99H		c                   \        \        P                  4       F-  pVP                  R 4      '       g   K  \        P                  V K/  	  \        ^8  d   \        R4       \        P                  ^  \        ^8  d   \        R4       \        P                  ! VRR7       F  w  r4pV F7  p \        P                  ! \        P                  P                  W64      4       K9  	  V F9  p\        P                  P                  W64      p \        P                  ! V4       K;  	  K  	   \        P                  ! V4       \        ^8  d   \        R4       R# R#   \         d(   p\        ^8  d   \        T4        Rp?K   Rp?K  Rp?ii ; i  \         d(   p\        ^8  d   \        T4        Rp?K   Rp?K  Rp?ii ; i  \         d(   p\        ^8  d   \        T4        Rp?R#  Rp?R# Rp?ii ; i)r   z  Removed sys.modules entriesz  Removed sys.path entryF)topdownNz  Removed package tree)r)   r   rE   r*   r   r   r   r   walkremover   OSErrorrmdir)	r4   topentryrootdirsfilesrR   exfullnames	   &&       r=   _del_pkgRunModuleTestCase._del_pkg  sV   #++&E00KK& ' Q;=>HHQKQ;89!#e!<D.IIbggll467 
 77<<3.HHX&  "=	&HHSM{E":;{  .{E"II{.  .{E"II{.
  	&{E"II{	&sH   ,3EF',G F	"FF	F>F99F>G3G..G3c                   R pVR;;,          V,          uu&   VR,          VR&   VR,          p\         P                  P                  VP                  VR,          4      pWQR&   V'       d   VR;;,          V,          uu&   R# R# )cr   r   r   r   N)rr   r   r   rR   )r4   ns	alter_syschar_to_addspecnew_specs   &&&   r=   _fix_ns_for_legacy_pyc(RunModuleTestCase._fix_ns_for_legacy_pyc  sk    
:+%j><*~>>99$)):<Z.J!:{O{*O r@   c               v  aa
 V P                  \        VVVR 7      w  rVo
p\        S
4       \        P	                  4       pVP                  RS
RVRVP                  RS
P                  R4      ^ ,          RV/4       S'       d   VP                  RVRR	R
R	/4       VV
3R lp	 \        ^8  d   \        RS
4       V P                  W4       \        P                  ! 4        \        S
4       \        P                  ! V4       \         P"                  '       gf   \%        V4       \'        S
4       \        P                  ! 4        \        ^8  d   \        RS
4       V P)                  VS4       V P                  W4       V P+                  V4       \        ^8  d   \        R4       R# R#   T P+                  T4       i ; i)r   r   r   r   r   r   r   r   r   r   Tr    c                     < \        SV SR 7      # r   r   )re   r   ro   s   &r=   rf   2RunModuleTestCase._check_module.<locals>.create_ns=      h	JJr@   Running from source:Running from compiled:Module executed successfullyN)r   rd   r	   rh   r(   ri   rU   
rpartitionr   r   rO   rr   invalidate_caches
__import__r   r   r   dont_write_bytecoder
   r   r   r   )r4   r   r   r   r   r   ru   rp   r6   rf   ro   s   &&f$$     @r=   _check_moduleRunModuleTestCase._check_module(  sy    ~~ne(10A  C 	/Hh 	x',,.	(//8..s3A6
 	 Y)4'  
	K	#{E"8(C%%i='')x IIi ***	*x ++-Q;&> I++KC)))AMM'"Q;<=; MM'"s   !CF% %F8c                 aa V P                  \        VR VVR7      w  rVrxVP                  R4      ^ ,          o\        V4       \        P                  4       p	V	P                  RVRVR\        P                  P                  V4      RSRV/4       S'       d   V	P                  RVR	R
RR
/4       VV3R lp
 \        ^8  d   \        RS4       V P                  W4       \        P                  ! 4        \        V4       \        P                   ! V4       \"        P$                  '       gf   \'        V4       \)        V4       \        ^8  d   \        RS4       \        P                  ! 4        V P+                  V	S4       V P                  W4       V P-                  V4       \        ^8  d   \        R4       R# R#   T P-                  T4       i ; i)__main__r   r   r   r   r   r   r   r   r   Tr    c                     < \        SV SR 7      # r   r   )re   r   r   s   &r=   rf   3RunModuleTestCase._check_package.<locals>.create_nsf  r   r@   r   r   zPackage executed successfullyN)r   rd   r   r	   rh   r(   ri   rr   r   cache_from_sourcer   r   rO   r   r   r   r   r   r   r
   r   r   r   )r4   r   r   r   r   r   ru   ro   rp   r6   rf   r   s   &&f$$      @r=   _check_package RunModuleTestCase._check_packageP  s    ~~neZ(10A  C 	/H &&s+A.x',,.	)..::9E8
 	 Y)4'  
	K	#{E"8(C%%i='')x IIi ***	*x Q;&> I++-++KC)))AMM'"Q;=>; MM'"s   6CF: :Gc                   V^8:  d   \        R4      hRpTp\        V4       F$  pTp\        P                  P	                  WT4      pK&  	  \        P                  P	                  VR4      p\        V4       \        ^8  d   \        RV4       \        P                  P	                  XR4      p	V P                  V	4       \        ^8  d   \        RV	4       \        P                  P	                  V	R4      p
V P                  V
4       \        ^8  d   \        RV
4       \        P                  P	                  V
R	4      p\        V4       \        ^8  d   \        R
V4       R# R# )   z$Relative module test needs depth > 1r   z
sibling.pyz  Added sibling module:unclez  Added uncle package:cousinz  Added cousin package:z	nephew.pyz  Added nephew module:N)	
ValueErrorranger   r   r   r   r   r   r   )r4   base_dirr   r   r   
module_diri
parent_dirsibling_fname	uncle_dir
cousin_dirnephew_fnames   &&&&        r=   _add_relative_modules'RunModuleTestCase._add_relative_modulesy  s   A:CDD"
uA#Jj;J  Z>-(Q;7GGGLLW5	)$Q;6	BWW\\)X6
*%Q;7Dww||J<,'Q;6E;r@   Nc                   R pV P                  W14      w  rErgVf   TpMTp V P                  WCV4       VP                  R4      ^ ,          p	\        ^8  d   \	        RV4       \        WbR7      p
V P                  V
R,          V4       V P                  V
R,          V	4       V P                  RV
4       V P                  RV
4       ?
\        P                  ! 4        \        V4       \        P                  ! V4       \        P                  '       g   \        V4       \!        V4       \        ^8  d   \	        R	V4       \        P                  ! 4        \        WbR7      pV P                  VR,          V4       V P                  VR,          V	4       V P                  RV4       V P                  RV4       ?V P#                  V4       \        ^8  d   \	        R
4       R# R#   T P#                  T4       i ; i)za\
from __future__ import absolute_import
from . import sibling
from ..uncle.cousin import nephew
Nr   r   )rK   r   r   siblingnephewr   r   )r   r   r   r   r   r   r/   assertInrr   r   r   r   r   r   r   r
   r   r   )r4   r   rK   contentsr   ru   ro   rp   expected_namer   d1d2s   &&&         r=   _check_relative_imports)RunModuleTestCase._check_relative_imports  s    ~~h. 	/H$M$M	#&&w%@**3/2H{E"8(CH8BR
^];R.9MM)R(MM(B''')x IIi ***	*x Q;&> I++-<  J?  M!2H=i,h+MM'"Q;<=; MM'"s   FG! !G4c                z    \        ^4       F+  p\        ^8  d   \        RV4       V P                  V4       K-  	  R# )   Testing package depth:Nr   r   r   r   r4   r   s   & r=   test_run_module!RunModuleTestCase.test_run_module  s/    1XE{E":EBu% r@   c                    \        ^^4       F.  p\        ^8  d   \        RV4       V P                  VRRR7       K0  	  R# r   r   Tr   Nr   r   s   & r=   $test_run_module_in_namespace_package6RunModuleTestCase.test_run_module_in_namespace_package  s8    1a[E{E":EBuM !r@   c                |    \        ^^4       F+  p\        ^8  d   \        RV4       V P                  V4       K-  	  R# )r   r   Nr   r   r   r   r   s   & r=   test_run_package"RunModuleTestCase.test_run_package  s1    1a[E{E":EB& !r@   c           
        V P                  R ^R4      pVw  r#rCVP                  RR 4      pV P                  V P                  V4       \        P
                  P                  VRR4      p\        \        \        \        3pV F  pVP                  pV P                  V4      ;_uu_ 4        RP                  V4      p	\        VRRR7      ;_uu_ 4       p
V
P                  V	4       R	R	R	4        \!        V4       V P#                  R
P                  V4      4        \!        VR,           4       V P#                  R
P                  V4      4       R	R	R	4       K  	  R	#   + '       g   i     L}; i  T d&   pT P%                  R\        T4      4        R	p?L{R	p?ii ; i  T d&   pT P%                  R\        T4      4        R	p?LwR	p?ii ; i  + '       g   i     EKZ  ; i)rm   r   	.__main__r   r   z raise {0}('{0} in __init__.py.')wtasciiencodingNzNothing raised; expected {}zfinding specz
.submodule)r   replace
addCleanupr   r   r   r   r~   AttributeError	TypeErrorr   r   subTestformatr   r   r   r}   assertNotIn)r4   r   r   _ro   init
exceptions	exceptionrR   r   r   errs   &           r=    test_run_package_init_exceptions2RunModuleTestCase.test_run_package_init_exceptions  s   Az2"(H##K4w/ww||G_mD!>9jI
#I%%Dd##;BB4H$w778NN6* 8Jx( II;BB4HIJx,67 II;BB4HI $# $ 87 ! B$$^VC[AAB ! B$$^VC[AAB $##sx   ((GE"G+E*6 GF) GE'"G*F	1F	GF	GG	 G 	;G G	GGc                    V P                  R ^4      w  rr2 \        V4       V P                  \        R4      ;_uu_ 4        \	        V4       RRR4       V P                  V4       R#   + '       g   i     L#; i  T P                  T4       i ; i)rm   found in sys\.modulesN)r   r   assertWarnsRegexRuntimeWarningr   r   )r4   r   r  ro   s   &   r=   test_submodule_imported_warning1RunModuleTestCase.test_submodule_imported_warning  sq    "&..Q"7H	#x &&~,. .8$. MM'"	. . MM'"s#   )A:  A'A: 'A7	2A: :Bc                D   V P                  R ^R4      w  rr2V P                  V P                  V4       VP                  RR 4      p\	        V4       V P                  V\        P                  4       \        P                  ! 4       ;_uu_ 4        \        P                  ! R\        4       \        V4       RRR4       \	        V4       V P                  \        R4      ;_uu_ 4        \        V4       RRR4       R#   + '       g   i     LO; i  + '       g   i     R# ; i)rm   r   r  errorNr  )r   r  r   r  r   r   r   rE   warningscatch_warningssimplefilterr!  r   r   )r4   r   r  ro   packages   &    r=    test_package_imported_no_warning2RunModuleTestCase.test_package_imported_no_warning  s    "&..Q
"CHw/"";37gs{{+$$&&!!'>:w ' 	8"">3KLLw ML '&
 MLLs   'C;%D;D	D	c                    \        ^^4       F-  p\        ^8  d   \        RV4       V P                  VRR7       K/  	  R# )r   r   T)r   Nr  r   s   & r=   %test_run_package_in_namespace_package7RunModuleTestCase.test_run_package_in_namespace_package  s6    1a[E{E":EB> !r@   c                    \        ^^4       F-  p\        ^8  d   \        RV4       V P                  VRR7       K/  	  R# )r   r   T)r   Nr  r   s   & r=   test_run_namespace_package,RunModuleTestCase.test_run_namespace_package  6    1a[E{E":EB6 !r@   c                    \        ^^4       F.  p\        ^8  d   \        RV4       V P                  VRRR7       K0  	  R# r  r  r   s   & r=   /test_run_namespace_package_in_namespace_packageARunModuleTestCase.test_run_namespace_package_in_namespace_package  s8    1a[E{E":EBN !r@   c                ~    \        ^4       F-  p\        ^8  d   \        RV4       V P                  VRR7       K/  	  R# )r   r   Tr   Nr   r   s   & r=   test_run_module_alter_sys+RunModuleTestCase.test_run_module_alter_sys  s4    1XE{E":EBu5 r@   c                    \        ^^4       F-  p\        ^8  d   \        RV4       V P                  VRR7       K/  	  R# )r   r   Tr   Nr  r   s   & r=   test_run_package_alter_sys,RunModuleTestCase.test_run_package_alter_sys  r2  r@   c                |    \        ^^4       F+  p\        ^8  d   \        RV4       V P                  V4       K-  	  R# )   z"Testing relative imports at depth:Nr   r   r   r   r   s   & r=   test_explicit_relative_import/RunModuleTestCase.test_explicit_relative_import  s1    1a[E{E"FN((/ !r@   c                ~    \        ^^4       F,  p\        ^8  d   \        RV4       V P                  VR4       K.  	  R# )r=  z'Testing main relative imports at depth:r   Nr>  r   s   & r=   test_main_relative_import+RunModuleTestCase.test_main_relative_import  s3    1a[E{E"KUS((
; !r@   c                  aa ^pRoV P                  \        V4      w  r#op\        S4       \        P	                  4       pVP                  RSRVR\        P                  P                  V4      RSP                  R4      ^ ,          RV/4       VV3R lp V P                  We4       V P                  V4       R	#   T P                  T4       i ; i)
r   z*And now for something completely differentr   r   r   r   r   r   c                    < \        SV S4      # rc   r   )re   ro   rK   s   &r=   rf   2RunModuleTestCase.test_run_name.<locals>.create_ns-  s    hh??r@   N)r   rd   r	   rh   r(   ri   rr   r   r   r   rO   r   )	r4   r   r   ru   rp   r6   rf   ro   rK   s	   &      @@r=   test_run_nameRunModuleTestCase.test_run_name  s    ?~~ne4 	/Hhx',,.	)..::9E8..s3A6
 		@	#%%i=MM'"DMM'"s   B: :Cc                   ^ RI p^pRpRR.pRVR,           .p\        4       p\        4       p\        ^V4       F}  pRP                  V.V,          4      p	VP	                  V	4       V F"  p
VP	                  V	R,           V
,           4       K$  	  V F"  p
VP	                  V	R,           V
,           4       K$  	  K  	  RP                  V.V,          4      p	VP	                  V	4       VP	                  V	R,           4       V P                  R	V4      w  rrV P                  V P                  V4       \        ^V^,           4       F  pV P                  VR	V4       K  	  VP                  V.4       F  pV P                  WP                  4       V P                  VP                  \        P                  P                  4       VP                   '       d   VP#                  VP$                  4       K  VP#                  VP$                  4       K  	  V P'                  \)        V4      ^ V4       V P'                  \)        V4      ^ V4       R# )
r   Nr   r   zuncle.cousinzuncle.cousin.nephewz.siblingr   z.runpy_testrm   )pkgutilr3   r   r   addr   r  r   r   walk_packagesassertIsInstance
ModuleInfomodule_finderrr   rs   
FileFinderispkgr   rR   r/   len)r4   rJ  	max_depth	base_namepackage_suffixesmodule_suffixesexpected_packagesexpected_modulesr   r   rR   r   ru   ro   rp   
moduleinfos   &               r=   test_pkgutil_walk_packages,RunModuleTestCase.test_pkgutil_walk_packages4  s    		#	#^40)j2HIE51i(Exxe 34H!!(+(!%%hnt&;< )' $$X^d%:; ( ) 88YK)34h'X56~~b), 	/Hw/1ik*E&&wE: +!//	:J!!*.@.@A!!*":":"+"5"5"@"@B!((9 ''
8 ; 	./4EF-.3CDr@   rQ   )F)
runpy_testrc   )!r   rX   rY   rZ   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r"  r*  r-  r0  r4  r7  r:  r?  rB  rG  rZ  r[   r\   r]   s   @r=   r{   r{      s     )?4C6"'6;@6:&2	+&>&+&>?D&>P'?','?@E'?RF.&>P&
N
'
J8# ?
7
O
6
7
0
<
#*"E "Er@   r{   c                      a  ] tR tRt o RtRR ltRR ltR tR tR t	R	 t
R
 tR tR tR tR tR tR t]]! R4      R 4       4       tR tRtV tR# )RunPathTestCaseiX  zUnit tests for runpy.run_pathNc                .    Vf   \         p\        WW44      # rc   )rd   r   )r4   
script_dirscript_basenamer   omit_suffixs   &&&&&r=   _make_test_script!RunPathTestCase._make_test_script[  s    >#F:!0 	0r@   c                4  aa V3R  lp\         P                  4       p	Vf   Tp
MTp
V'       d=   \        P                  P	                  V
V4      pVP
                  pV'       g   RVn        MR;rV	P                  RVRVRVRRRVRVR	R
RR
/4       V P                  W4       RoVV3R lpV'       d8   Vf4   \        P                  P	                  SV4      pV'       g   RVn        WR&   SV	R&   SP                  R4      ^ ,          V	R&   V P                  W4       R# )c                    < \        SV 4      # rc   r   )re   script_names   &r=   rf   0RunPathTestCase._check_script.<locals>.create_nsf  s    K66r@   Nr   r   r   r   rm   r   r   r   Tr    zprove.issue15230.is.fixedc                    < \        SV S4      # rc   rg  )re   rK   rh  s   &r=   rf   ri    s    Kx@@r@   r   )
rh   r(   rr   r   r   rU   r.   ri   rO   r   )r4   rh  r   expected_fileexpected_argv0ro   expect_speccheck_loaderrf   r6   	spec_namerp   
mod_cachedrK   s   &f&&&&&&     @r=   _check_scriptRunPathTestCase._check_scriptb  s   	7',,.%I I ~~==i>KMH!J"&$((H*2%t#T	
 		 	!!)9.	A8+ ~~==h>KMH"&&.
#"*J%-%8%8%=a%@M"!!)9r@   c                j    \         P                  ! V4      pV P                  \        V\        V4       R # rc   )reescapeassertRaisesRegexr~   r   )r4   rh  msgs   &&&r=   _check_import_error#RunPathTestCase._check_import_error  s#    iin{C;Gr@   c           
         \        4       ;_uu_ 4       pR pV P                  W4      pV P                  VRVVRR7       RRR4       R#   + '       g   i     R# ; iscript
<run_path>Frm  Nr   rc  rq  r4   r`  ro   rh  s   &   r=   test_basic_script!RunPathTestCase.test_basic_script  sJ    ZZ:H00FK{L+*  ? ZZZs   *AA	c           
         \        4       ;_uu_ 4       pR pV P                  W4      pV P                  \        V4      RVVRR7       RRR4       R#   + '       g   i     R# ; ir{  )r   rc  rq  r   r  s   &   r=   &test_basic_script_with_pathlike_object6RunPathTestCase.test_basic_script_with_pathlike_object  sQ    ZZ:H00FKx4l**+0  2 ZZZs   3AA!	c           
         \        4       ;_uu_ 4       pR pV P                  WRR7      pV P                  VRVVRR7       RRR4       R#   + '       g   i     R# ; i)r|  T)rb  r}  Fr~  Nr  r  s   &   r=   test_basic_script_no_suffix+RunPathTestCase.test_basic_script_no_suffix  sU    ZZ:H00=A 1 CK{L+*  ?	 ZZZs   ,A		A	c           
        \        4       ;_uu_ 4       pR pV P                  W4      p\        P                  ! VRR7      p\        P
                  ! V4       V P                  VRVVRR7       RRR4       R#   + '       g   i     R# ; i)r|  Tdoraiser}  Fr~  N)r   rc  
py_compilecompiler   r   rq  )r4   r`  ro   rh  compiled_names   &    r=   test_script_compiled$RunPathTestCase.test_script_compiled  si    ZZ:H00FK&..{DIMIIk"}lM,%  A ZZZs   AA55B	c           
         \        4       ;_uu_ 4       pR pV P                  W4      pV P                  VRVWR7       RRR4       R#   + '       g   i     R# ; i)r   r}  ro   Nr  r  s   &   r=   test_directoryRunPathTestCase.test_directory  sH    ZZ:!H00FKz<)  > ZZZs   )AA	c           
     R   \        4       ;_uu_ 4       pR pV P                  W4      p\        P                  ! VRR7      p\        P
                  ! V4       \        P                  '       g!   \        V4      pV P                  VRVWR7       RRR4       R#   + '       g   i     R# ; i)r   Tr  r}  r  N)
r   rc  r  r  r   r   r   r   r
   rq  )r4   r`  ro   rh  r  
legacy_pycs   &     r=   test_directory_compiled'RunPathTestCase.test_directory_compiled  s}    ZZ:!H00FK&..{DIMIIk"***,[9
"":|Z#- # B ZZZs   A8BB&	c                    \        4       ;_uu_ 4       pR pV P                  W4      pRV,          pV P                  W4       RRR4       R#   + '       g   i     R# ; i)not_main"can't find '__main__' module in %rN)r   rc  rx  )r4   r`  ro   rh  rw  s   &    r=   test_directory_error$RunPathTestCase.test_directory_error  sD    ZZ:!H00FK6CC$$Z5	 ZZZs   .AA	c                    \        4       ;_uu_ 4       pR pV P                  W4      p\        VRV4      w  rEV P                  VRWTVRR7       RRR4       R#   + '       g   i     R# ; i)r   test_zipr}  Fro   rn  N)r   rc  r   rq  )r4   r`  ro   rh  zip_namefnames   &     r=   test_zipfileRunPathTestCase.test_zipfile  s[    ZZ:!H00FK-j*kROHxu(0u  F	 ZZZs   9AA'	c                   \        4       ;_uu_ 4       pR pV P                  W4      p\        P                  ! VRR7      p\	        VRV4      w  rVV P                  VRWeVRR7       RRR4       R#   + '       g   i     R# ; i)r   Tr  r  r}  Fr  N)r   rc  r  r  r   rq  )r4   r`  ro   rh  r  r  r  s   &      r=   test_zipfile_compiled%RunPathTestCase.test_zipfile_compiled  sp    ZZ:!H00FK&..{DIM-j*.;=OHxu(0u  F ZZZs   AA..A?	c                    \        4       ;_uu_ 4       pR pV P                  W4      p\        VRV4      w  rERV,          pV P                  WF4       RRR4       R#   + '       g   i     R# ; i)r  r  r  N)r   rc  r   rx  )r4   r`  ro   rh  r  r  rw  s   &      r=   test_zipfile_error"RunPathTestCase.test_zipfile_error  sT    ZZ:!H00FK-j*kROH6AC$$X3 ZZZs   =AA+	cpuc                   \        4       ;_uu_ 4       p\        4       ;_uu_ 4       pR pRV,          pV P                  WV4      p\        VRV4      w  rg\        ^4      ;_uu_ 4        V P	                  \
        \        V4       RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)r   z import runpy
runpy.run_path(%r)
r  N)r   rc  r   r   assertRaisesRecursionErrorr   )r4   r`  	dummy_dirro   r   rh  r  r  s   &       r=   test_main_recursion_error)RunPathTestCase.test_main_recursion_error  s     ZZ:xzzY!H-09:F00vNK-j*kROH#B''!!.(HE ( (2ZZ (' (2zZZZs;   CA B/	&BB/	
CB,'B/	/B?:CC	c           	     r   \        4       ;_uu_ 4       p\        P                  P                  VR 4      p\	        VRRR7      ;_uu_ 4       pVP                  R4       RRR4       \        V4      pV P                  VR,          R4       RRR4       R#   + '       g   i     L>; i  + '       g   i     R# ; i)z	script.pyr   latin1r  u%   
#coding:latin1
s = "non-ASCII: hé"
Nsu   non-ASCII: hé)r   r   r   r   r   r   r   r/   )r4   r`  filenamefr   s   &    r=   test_encodingRunPathTestCase.test_encoding  s    ZZ:ww||J<Hhh771   8
 h'FVC[*<= Z77 ZZs#   7B%
B	,B%B"B%%B6	rQ   )NF)NTT)r   rX   rY   rZ   r   rc  rq  rx  r  r  r  r  r  r  r  r  r  r  r   r   r  r  r[   r\   r]   s   @r=   r^  r^  X  s|     '0+:ZH?2?A>	B6FF4 uF  F	> 	>r@   r^  c                      a a ] tR tRt oRt]P                  R8X  d   ]M]P                  ) t	]
]P                  R 4       4       tV 3R lt]! 4       R 4       tR tR tR	 tR
 tR tR tR tRtVtV ;t# )TestExiti  l   :   win32c               /     "   \        4       ;_uu_ 4       p\        P                  ! V4      x  R R R 4       R #   + '       g   i     R # ; i5irc   )r   pathlibPath)argskwargstmp_fns   *, r=   tmp_pathTestExit.tmp_path  s*      ZZ6,,v&& ZZZs   A8
AA			Ac                   < V P                  4       ;_uu_ 4       pVR ,          ;V n        pVP                  \        P                  ! R4      4       \
        SV `  ! V/ VB  RRR4       R#   + '       g   i     R# ; i)zham.pyz@                    raise KeyboardInterrupt
                    N)r  ham
write_texttextwrapdedentsuperrun)r4   r  r  tmpr  	__class__s   &*,  r=   r  TestExit.run  s\    ]]__ 8^+DHsNN GK(( ___s   AA**A;	c                   \         P                  R .VOp\        P                  ! V.VO5/ VBRRR\        P                  /B pV P                  VP                  R4       V P                  VP                  V P                  4       R# )z-EtextTstderrz
KeyboardInterrupt
N)
r   
executable
subprocessr  PIPEassertEndsWithr  r/   
returncodeEXPECTED_CODE)r4   cmdr  r  procs   &&*, r=   assertSigIntTestExit.assertSigInt  sl     ~~t*c*~~cVDVFVVjooVDKK)@A$*<*<=r@   c                >    V P                  V P                  .4       R # rc   )r  r  r   s   &r=   test_pymain_run_fileTestExit.test_pymain_run_file"  s    488*%r@   c                    V P                   P                  pVR ,          pVP                  ! \        P                  ! R4      4       V P                  V.VR7       R# )zrun_module.pyzU                import runpy
                runpy.run_module("ham")
                cwdNr  rS   r  r  r  r  )r4   r  r   s   &  r=   %test_pymain_run_file_runpy_run_module.TestExit.test_pymain_run_file_runpy_run_module%  sO    hhoo?*
OO	
 	:,C0r@   c                    V P                   P                  pVR ,          pVP                  \        P                  ! R4      4       V P                  V.VR7       R# )zrun_module_as_main.pyz^                import runpy
                runpy._run_module_as_main("ham")
                r  Nr  )r4   r  run_module_as_mains   &  r=   -test_pymain_run_file_runpy_run_module_as_main6TestExit.test_pymain_run_file_runpy_run_module_as_main2  sS    hhoo #::%%OO	
 	-.C8r@   c                X    V P                  R R.V P                  P                  R7       R# )-cz%import runpy; runpy.run_module('ham')r  Nr  r  rS   r   s   &r=   "test_pymain_run_command_run_module+TestExit.test_pymain_run_command_run_module?  s)    :; 	 	
r@   c                X    V P                  R R.V P                  P                  R7       R# )r  
import hamr  Nr  r   s   &r=   test_pymain_run_command TestExit.test_pymain_run_commandE  s"    4.DHHOODr@   c                V    V P                  . R V P                  P                  R7       R# )r  )inputr  Nr  r   s   &r=   test_pymain_run_stdinTestExit.test_pymain_run_stdinH  s    "LdhhooFr@   c                p    V P                   pV P                  R VP                  .VP                  R7       R# )z-mr  N)r  r  stemrS   )r4   r  s   & r=   test_pymain_run_moduleTestExit.test_pymain_run_moduleK  s+    hh4*

;r@   )r  )r   rX   rY   rZ   STATUS_CONTROL_C_EXITr   platformsignalSIGINTr  staticmethod
contextlibcontextmanagerr  r  r   r  r  r  r  r  r  r  r  r[   r\   __classcell__)r  r^   s   @@r=   r  r    s     & <<7" 	mm^ 
 '  '

) > >&19
EG< <r@   r  r   )5r  importlib.machineryrr   importlib.utilos.pathr   r  r  rt  r  r  r   r   r  unittestr&  test.supportr   r   r   r   r   r   test.support.import_helperr	   r
   r   test.support.os_helperr   r   r   test.support.script_helperr   r   r   r   r   r   r   rd   implicit_namespacerD   dictrh   ri   r%   TestCaser`   r{   r^  r  r   mainrQ   r@   r=   <module>r     sr    *    	   
      G F H H C  C C& $4t  
3U%'>?!uUd%T;	    + ,LF LF^$:X..0B $:NUE))+= UEnd>h''); d>N  M<x   M<  M<` zMMO r@   