o
    HXhr                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlmZmZ d dlmZmZmZ d dlmZmZ d dlmZmZ d dlZd dlmZmZm Z m!Z! dZ"dddddddZ#eed	d
gej$d  dde%e#dddddZ&e&'e# G dd dZ(G dd dej)e(Z*G dd dej)e(Z+G dd dej)e(Z,G dd dej)Z-e.dkre/  dS dS )    N)
no_tracingverbose)forgetmake_legacy_pycunload)create_empty_filetemp_dir)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__zTop level assignmentzLower level referenceF   z<run>)xr   
__loader__)sysrunpyresult	run_argv0run_name_in_sys_modulesmodule_in_sys_modulesnestedc                   @   s$   e Zd Zg dZdd Zdd ZdS )CodeExecutionMixin)nameparentorigincachedhas_locationsubmodule_search_locationsc           	      C   s*  |  }|  }t|D ]"}|dr.|dr.||vr!|| ||d vr.|d | q|d}|d}|du rC| | n/|jdurT| t|jt|j | j	D ]}d| }|t
||f}|t
||f}| || qW| t|t| |D ]}||| f}||| f}| || q~dS )zbCheck two namespaces match.

           Ignores any unspecified interpreter created names
        __r   r   Nz	__spec__.)copylist
startswithendswithpopZassertIsNoneloaderassertEqualtypeCHECKED_SPEC_ATTRIBUTESgetattrset)	self	result_nsexpected_nskZresult_specZexpected_specattractualZexpected r8   9/opt/python-3.10.19/usr/lib/python3.10/test/test_runpy.pyassertNamespaceMatchesP   s8   




z)CodeExecutionMixin.assertNamespaceMatchesc           
      C   s   t  }| }|d }tjd }tj||}|d}| || | tjd | | tj||| d|i}	||d< ||	}| ||	 | || | tjd | | tj||| dS )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   r   Nsentinel)	objectr'   r   argvmodulesgetr:   ZassertIsZassertIsNot)
r2   Zcreate_namespaceZexpected_namespacer;   r4   run_nameZsaved_argv0Z	saved_modr3   Z
initial_nsr8   r8   r9   check_code_executionx   s    
z'CodeExecutionMixin.check_code_executionN)r   
__module____qualname__r/   r:   rA   r8   r8   r8   r9   r   D   s    	(r   c                   @   s    e Zd ZdZdd Zdd ZdS )ExecutionLayerTestCasez9Unit tests for runpy._run_code and runpy._run_module_codec                 C   s.   t  }|dd i dd }| || d S )Nr   c                 S   s   t ti | S N)r   example_sourceZinit_globalsr8   r8   r9   	create_ns      z7ExecutionLayerTestCase.test_run_code.<locals>.create_ns)example_namespacer'   updaterA   )r2   r4   rH   r8   r8   r9   test_run_code   s   z$ExecutionLayerTestCase.test_run_codec                    sd   d d}d}d}t jj ||dt }| ||||ddd  fdd	}| || d S )
Nz
<Nonsense>zSome other nonsensezNow you're just being silly )r"   r,   T)r   r   r   r   r   r   r   r   c                    s   t t|  S rE   )r   rF   rG   mod_namemod_specr8   r9   rH      s
   z>ExecutionLayerTestCase.test_run_module_code.<locals>.create_ns)	importlib	machinery
ModuleSpecrJ   r'   rK   rA   )r2   	mod_fnameZ
mod_loaderZmod_packager4   rH   r8   rN   r9   test_run_module_code   s*   
z+ExecutionLayerTestCase.test_run_module_codeN)r   rB   rC   r   rL   rU   r8   r8   r8   r9   rD      s    	rD   c                   @   s  e Zd ZdZdd Zdd Zdd Zd:d	d
Zd;dddddZdd Z	dd Z
d:dddddZd:dddddZdd Zd<ddZdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 ZdS )=RunModuleTestCasezUnit tests for runpy.run_modulec                 C   s4   zt | W n
 ty   Y d S w | d|  d S )NzExpected import error for )r   ImportErrorfail)r2   rO   r8   r8   r9   expect_import_error   s   z%RunModuleTestCase.expect_import_errorc                 C   s^   |  d |  d |  d |  d |  d |  d |  d |  d |  d	 d S )
Nr   zsys.imp.ericzos.path.halfza.beez.howardz..eatenz.test_runpyz	.unittestmultiprocessing)rY   r2   r8   r8   r9   test_invalid_names   s   







z$RunModuleTestCase.test_invalid_namesc                 C   s   |  tdd d d S )Nr   r   )r-   r   r[   r8   r8   r9   test_library_module   s   z%RunModuleTestCase.test_library_moduleFc                 C   s,   t | |r	d S t j|d}t| |S )N__init__.py)osmkdirpathjoinr   )r2   pkg_dir	namespace	pkg_fnamer8   r8   r9   _add_pkg_dir   s   
zRunModuleTestCase._add_pkg_dir
runpy_testrd   parent_namespacesc                C   sN  |s|r
|s
t dd}|tj d }tjt  }}	tdkr&td|	 t	j
d| tdkr9tdt	jd  |rh|g| }
||
d< |
D ]!}tj|	|}	| |	|}tdkr^td	|	 tdkrgtd
| qFtj|	|}t|d}|| W d    n1 sw   Y  tdkrtd
| |d | | }tj||}||||fS )Nz2Can't mark top level module as a namespace package__runpy_pkg__pyr   z  Package tree in:r   z  Updated sys.path:z  Next level in:z
  Created:w.)RuntimeErrorr_   extsepra   realpathtempfilemkdtempr   printr   insertrb   rf   openwriterQ   utilspec_from_file_location)r2   sourcedepthZmod_baserd   ri   pkg_nameZ
test_fnamerc   Zsub_dirZnamespace_flagsZnamespace_flagre   rT   mod_filerO   rP   r8   r8   r9   	_make_pkg   s6   
zRunModuleTestCase._make_pkgc           	      C   s  t tjD ]}|drtj|= qtdkrtd tjd= tdkr%td tj|ddD ]]\}}}|D ](}zt	tj
|| W q3 ty[ } ztdkrQt| W Y d }~q3d }~ww |D ]*}tj
||}zt| W q^ ty } ztdkr~t| W Y d }~q^d }~ww q,zt| tdkrtd W d S W d S  ty } ztdkrt| W Y d }~d S W Y d }~d S d }~ww )	Nrj   r   z  Removed sys.modules entriesr   z  Removed sys.path entryF)topdownz  Removed package tree)r(   r   r>   r)   r   rt   ra   r_   walkremoverb   OSErrorrmdir)	r2   topentryrootdirsfilesr    exfullnamer8   r8   r9   _del_pkg   s>   

,zRunModuleTestCase._del_pkgc                 C   s`   d}|d  |7  < |d |d< |d }t j|j|d }||d< |r.|d  |7  < d S d S )Ncr   r   r   r   )rQ   rx   ry   r    )r2   ns	alter_sysZchar_to_addspecZnew_specr8   r8   r9   _fix_ns_for_legacy_pyc  s   
z(RunModuleTestCase._fix_ns_for_legacy_pycc          
   	      s$  | j t|||d\}}}t t }|||jdd |d  r1||ddd  fdd}	zGtd	krBt	d
 | 
|	| t  t t| tjsyt| t t  td	krmt	d | |  | 
|	| W | | n| | w td	krt	d d S d S )Nrh   rn   r   r   r   r   r   r   Tr   r   r   c                       t |  dS Nr   r   rG   r   rO   r8   r9   rH   6     z2RunModuleTestCase._check_module.<locals>.create_nsr   Running from source:Running from compiled:Module executed successfully)r~   rF   r   rJ   r'   rK   r#   
rpartitionr   rt   rA   rQ   invalidate_caches
__import__r_   r   r   dont_write_bytecoder   r   r   r   )
r2   r{   r   rd   ri   rc   rT   rP   r4   rH   r8   r   r9   _check_module!  sJ   

zRunModuleTestCase._check_modulec             	      s0  | j t|d||d\}}}}|dd t| t }	|	||tj	||d  r7|	|ddd  fdd	}
zGt
d
krHtd | |
|	 t  t| t| tjst| t| t
d
krotd t  | |	  | |
|	 W | | n| | w t
d
krtd d S d S )N__main__rh   rn   r   r   Tr   c                    r   r   r   rG   r   r|   r8   r9   rH   _  r   z3RunModuleTestCase._check_package.<locals>.create_nsr   r   r   zPackage executed successfully)r~   rF   r   r   rJ   r'   rK   rQ   rx   cache_from_sourcer   rt   rA   r   r   r_   r   r   r   r   r   r   r   )r2   r{   r   rd   ri   rc   rT   rO   rP   r4   rH   r8   r   r9   _check_packageI  sL   



z RunModuleTestCase._check_packagec                 C   s   |dkrt dd}|}t|D ]}|}tj||}qtj|d}t| tdkr0td| tj|d}	| |	 tdkrEtd|	 tj|	d}
| |
 tdkrZtd	|
 tj|
d
}t| tdkrptd| d S d S )Nr   z$Relative module test needs depth > 1rj   z
sibling.pyz  Added sibling module:unclez  Added uncle package:Zcousinz  Added cousin package:z	nephew.pyz  Added nephew module:)	
ValueErrorranger_   ra   rb   r   r   rt   rf   )r2   base_dirrz   r{   r|   Z
module_diriZ
parent_dirZsibling_fnameZ	uncle_dirZ
cousin_dirZnephew_fnamer8   r8   r9   _add_relative_modulesr  s&   

z'RunModuleTestCase._add_relative_modulesNc              	   C   sb  d}|  ||\}}}}|d u r|}n|}z| ||| |dd }	tdkr-td| t||d}
| |
d | | |
d |	 | d	|
 | d
|
 ~
t	  t
| t| tjst| t| tdkrqtd| t	  t||d}| |d | | |d |	 | d	| | d
| ~W | | n| | w tdkrtd d S d S )Nza\
from __future__ import absolute_import
from . import sibling
from ..uncle.cousin import nephew
rn   r   r   r   )r@   r   r   ZsiblingZnephewr   r   )r~   r   r   r   rt   r   r-   assertInrQ   r   r   r_   r   r   r   r   r   r   )r2   r{   r@   contentsrc   rT   rO   rP   expected_namer|   Zd1Zd2r8   r8   r9   _check_relative_imports  sB   


z)RunModuleTestCase._check_relative_importsc                 C   s.   t dD ]}tdkrtd| | | qd S )N   r   Testing package depth:r   r   rt   r   r2   r{   r8   r8   r9   test_run_module  s   z!RunModuleTestCase.test_run_modulec                 C   6   t ddD ]}tdkrtd| | j|ddd qd S Nr   r   r   Trh   r   r   r8   r8   r9   $test_run_module_in_namespace_package     z6RunModuleTestCase.test_run_module_in_namespace_packagec                 C   s0   t ddD ]}tdkrtd| | | qd S )Nr   r   r   r   r   rt   r   r   r8   r8   r9   test_run_package     z"RunModuleTestCase.test_run_packagec                 C   sx  |  ddd}|\}}}}|dd}| | j| tj|dd}ttt	t
f}|D ]}|j}| |} d|}	t|dd	d
}
|
|	 W d    n1 sQw   Y  zt| W n |yv } z| dt| W Y d }~nd }~ww | d| zt|d  W n |y } z| dt| W Y d }~nd }~ww | d| W d    n1 sw   Y  q*d S )NrM   r   r   	.__main__rj   r^   z raise {0}('{0} in __init__.py.')Zwtasciiencodingzfinding speczNothing raised; expected {}z
.submodule)r~   replace
addCleanupr   r_   ra   rb   rW   AttributeError	TypeErrorr   r   ZsubTestformatrv   rw   r   ZassertNotInrX   )r2   r   rc   _rO   Zinit
exceptions	exceptionr    rz   r}   errr8   r8   r9    test_run_package_init_exceptions  s>   
z2RunModuleTestCase.test_run_package_init_exceptionsc              	   C   s~   |  dd\}}}}z.t| | td t| W d    n1 s$w   Y  W | | d S W | | d S | | w )NrM   r   found in sys\.modules)r~   r   assertWarnsRegexRuntimeWarningr   r   )r2   rc   r   rO   r8   r8   r9   test_submodule_imported_warning  s   
z1RunModuleTestCase.test_submodule_imported_warningc                 C   s   |  ddd\}}}}| | j| |dd}t| | |tj t	  t
dt t| W d    n1 s<w   Y  t| | td t| W d    d S 1 s[w   Y  d S )NrM   r   r   r   errorr   )r~   r   r   r   r   r   r   r>   warningscatch_warningssimplefilterr   r   r   )r2   rc   r   rO   packager8   r8   r9    test_package_imported_no_warning  s   


"z2RunModuleTestCase.test_package_imported_no_warningc                 C   4   t ddD ]}tdkrtd| | j|dd qd S )Nr   r   r   T)ri   r   r   r8   r8   r9   %test_run_package_in_namespace_package     z7RunModuleTestCase.test_run_package_in_namespace_packagec                 C   r   )Nr   r   r   T)rd   r   r   r8   r8   r9   test_run_namespace_package  r   z,RunModuleTestCase.test_run_namespace_packagec                 C   r   r   r   r   r8   r8   r9   /test_run_namespace_package_in_namespace_package  r   zARunModuleTestCase.test_run_namespace_package_in_namespace_packagec                 C   s2   t dD ]}tdkrtd| | j|dd qd S )Nr   r   r   Tr   r   r   r8   r8   r9   test_run_module_alter_sys  s   z+RunModuleTestCase.test_run_module_alter_sysc                 C   r   )Nr   r   r   Tr   r   r   r8   r8   r9   test_run_package_alter_sys	  r   z,RunModuleTestCase.test_run_package_alter_sysc                 C   s0   t ddD ]}tdkrtd| | | qd S )N      r   z"Testing relative imports at depth:r   r   rt   r   r   r8   r8   r9   test_explicit_relative_import  r   z/RunModuleTestCase.test_explicit_relative_importc                 C   s2   t ddD ]}tdkrtd| | |d qd S )Nr   r   r   z'Testing main relative imports at depth:r   r   r   r8   r8   r9   test_main_relative_import  s   z+RunModuleTestCase.test_main_relative_importc              	      s   d}d|  t|\}} }t  t }||tj| 	dd |d  fdd}z| 
|| W | | d S | | w )Nr   z*And now for something completely differentrn   r   r   c                    s   t  | S rE   r   rG   rO   r@   r8   r9   rH   &  rI   z2RunModuleTestCase.test_run_name.<locals>.create_ns)r~   rF   r   rJ   r'   rK   rQ   rx   r   r   rA   r   )r2   r{   rc   rT   rP   r4   rH   r8   r   r9   test_run_name  s"   


zRunModuleTestCase.test_run_namec                 C   sx  dd l }d}d}ddg}d|d g}t }t }td|D ]+}d	|g| }	||	 |D ]}
||	d	 |
  q.|D ]}
||	d	 |
  q<qd	|g| }	||	 ||	d
  | d|\}}}}| | j| td|d D ]	}| |d| qu|	|gD ]"}| 
||j | 
|jtjj |jr||j q||j q| t|d| | t|d| d S )Nr   r   rj   r   zuncle.cousinzuncle.cousin.nephewz.siblingr   rn   z.runpy_testrM   r   )pkgutilr1   r   rb   addr~   r   r   r   Zwalk_packagesZassertIsInstanceZ
ModuleInfoZmodule_finderrQ   rR   
FileFinderZispkgr   r    r-   len)r2   r   Z	max_depth	base_nameZpackage_suffixesZmodule_suffixesZexpected_packagesZexpected_modulesr{   r|   r    rc   rT   rO   rP   Z
moduleinfor8   r8   r9   test_pkgutil_walk_packages-  sB   



z,RunModuleTestCase.test_pkgutil_walk_packages)F)rg   rE   )r   rB   rC   r   rY   r\   r]   rf   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r8   r8   r8   r9   rV      sD    
()
(
rV   c                   @   s   e Zd ZdZ	d#ddZ		d$ddZd	d
 Zdd Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zedd  Zd!d" ZdS )%RunPathTestCasezUnit tests for runpy.run_pathNFc                 C   s   |d u rt }t||||S rE   )rF   r	   )r2   
script_dirZscript_basenamerz   omit_suffixr8   r8   r9   _make_test_scriptT  s
   z!RunPathTestCase._make_test_scriptTc                    s   fdd}t  }	|d u r|}
n|}
|r%tj|
|}|j}|s$d |_nd  }}|	|||d||ddd | ||	 d  fdd}|r\|d u r\tj |}|sXd |_||	d<  |	d	<  	d
d |	d< | ||	 d S )Nc                    s
   t  | S rE   r   rG   )script_namer8   r9   rH   _  s   
z0RunPathTestCase._check_script.<locals>.create_nsrM   T)r   r   r   r   r   r   r   r   zprove.issue15230.is.fixedc                    s   t |  S rE   r   rG   r@   r   r8   r9   rH   |  rI   r   r   rn   r   r   )
rJ   r'   rQ   rx   ry   r#   r,   rK   rA   r   )r2   r   r   Zexpected_fileZexpected_argv0rO   expect_speccheck_loaderrH   r4   Z	spec_namerP   Z
mod_cachedr8   r   r9   _check_script[  sJ   
zRunPathTestCase._check_scriptc                 C   s   t |}| t|t| d S rE   )reescapeZassertRaisesRegexrW   r   )r2   r   msgr8   r8   r9   _check_import_error  s   
z#RunPathTestCase._check_import_errorc                 C   sP   t  }d}| ||}| j|d||dd W d    d S 1 s!w   Y  d S Nscript
<run_path>Fr   r   r   r   r2   r   rO   r   r8   r8   r9   test_basic_script     
"z!RunPathTestCase.test_basic_scriptc                 C   sV   t  }d}t| ||}| j|d||dd W d    d S 1 s$w   Y  d S r   )r   pathlibPathr   r   r   r8   r8   r9   "test_basic_script_with_path_object  s   

"z2RunPathTestCase.test_basic_script_with_path_objectc                 C   sT   t  }d}| j||dd}| j|d||dd W d    d S 1 s#w   Y  d S )Nr   T)r   r   Fr   r   r   r8   r8   r9   test_basic_script_no_suffix  s   
"z+RunPathTestCase.test_basic_script_no_suffixc                 C   sh   t  '}d}| ||}tj|dd}t| | j|d||dd W d    d S 1 s-w   Y  d S )Nr   Tdoraiser   Fr   )r   r   
py_compilecompiler_   r   r   )r2   r   rO   r   compiled_namer8   r8   r9   test_script_compiled  s   

"z$RunPathTestCase.test_script_compiledc                 C   sP   t  }d}| ||}| j|d|||d W d    d S 1 s!w   Y  d S )Nr   r   rO   r   r   r8   r8   r9   test_directory  r   zRunPathTestCase.test_directoryc                 C   s   t  6}d}| ||}tj|dd}t| tjs1t|}| j	|d|||d W d    d S W d    d S 1 s<w   Y  d S )Nr   Tr  r   r  )
r   r   r  r  r_   r   r   r   r   r   )r2   r   rO   r   r  Z
legacy_pycr8   r8   r9   test_directory_compiled  s   

"z'RunPathTestCase.test_directory_compiledc                 C   sP   t  }d}| ||}d| }| || W d    d S 1 s!w   Y  d S )Nnot_main"can't find '__main__' module in %r)r   r   r   )r2   r   rO   r   r   r8   r8   r9   test_directory_error  s   "z$RunPathTestCase.test_directory_errorc              	   C   sb   t  $}d}| ||}t|d|\}}| j|d|||dd W d    d S 1 s*w   Y  d S )Nr   test_zipr   FrO   r   )r   r   r
   r   )r2   r   rO   r   zip_namefnamer8   r8   r9   test_zipfile  s   "zRunPathTestCase.test_zipfilec              	   C   sp   t  +}d}| ||}tj|dd}t|d|\}}| j|d|||dd W d    d S 1 s1w   Y  d S )Nr   Tr  r  r   Fr  )r   r   r  r  r
   r   )r2   r   rO   r   r  r  r  r8   r8   r9   test_zipfile_compiled  s   "z%RunPathTestCase.test_zipfile_compiledc                 C   s`   t  #}d}| ||}t|d|\}}d| }| || W d    d S 1 s)w   Y  d S )Nr
  r  r  )r   r   r
   r   )r2   r   rO   r   r  r  r   r8   r8   r9   test_zipfile_error  s   "z"RunPathTestCase.test_zipfile_errorc              	   C   s   t  @}t  $}d}d| }| |||}t|d|\}}| tt| W d    n1 s.w   Y  W d    d S W d    d S 1 sFw   Y  d S )Nr   z import runpy
runpy.run_path(%r)
r  )r   r   r
   ZassertRaisesRecursionErrorr   )r2   r   Z	dummy_dirrO   rz   r   r  r  r8   r8   r9   test_main_recursion_error  s   Pz)RunPathTestCase.test_main_recursion_errorc              	   C   s   t  8}tj|d}t|ddd}|d W d    n1 s"w   Y  t|}| |d d W d    d S 1 s>w   Y  d S )Nz	script.pyrm   latin1r   u%   
#coding:latin1
s = "non-ASCII: hé"
su   non-ASCII: hé)r   r_   ra   rb   rv   rw   r   r-   )r2   r   filenamefr   r8   r8   r9   test_encoding  s   "zRunPathTestCase.test_encoding)NF)NTT)r   rB   rC   r   r   r   r   r   r   r   r  r  r	  r  r  r  r  r   r  r  r8   r8   r8   r9   r   Q  s*    

-	

	r   c                       s   e Zd ZdZejdkrenej Ze	e
jdd Z fddZdd Zd	d
 Zdd Zdd Zdd Zdd Zdd Zdd Z  ZS )TestExitl   :   win32c                  o   s:    t  }t|V  W d    d S 1 sw   Y  d S rE   )r   r   r   )argskwargsZtmp_fnr8   r8   r9   tmp_path  s   "zTestExit.tmp_pathc                    s^   |   !}|d  | _}|td t j|i | W d    d S 1 s(w   Y  d S )Nzham.pyz@                    raise KeyboardInterrupt
                    )r  ham
write_texttextwrapdedentsuperrun)r2   r  r  tmpr   	__class__r8   r9   r%    s   
"zTestExit.runc                 O   sB   t j|i |dt jd}| |jd | |j| j d S )NT)textstderrz
KeyboardInterrupt
)	
subprocessr%  PIPEZ
assertTruer*  r*   r-   
returncodeEXPECTED_CODE)r2   r  r  procr8   r8   r9   assertSigInt  s   zTestExit.assertSigIntc                 C   s   |  tj| jg d S rE   )r0  r   
executabler   r[   r8   r8   r9   test_pymain_run_file  s   zTestExit.test_pymain_run_filec                 C   8   | j j}|d }|td | jtj|g|d d S )Nzrun_module.pyzU                import runpy
                runpy.run_module("ham")
                cwdr   r!   r!  r"  r#  r0  r   r1  )r2   r&  r   r8   r8   r9   %test_pymain_run_file_runpy_run_module     z.TestExit.test_pymain_run_file_runpy_run_modulec                 C   r3  )Nzrun_module_as_main.pyz^                import runpy
                runpy._run_module_as_main("ham")
                r4  r6  )r2   r&  Zrun_module_as_mainr8   r8   r9   -test_pymain_run_file_runpy_run_module_as_main$  r8  z6TestExit.test_pymain_run_file_runpy_run_module_as_mainc                 C      | j tjddg| jjd d S )N-cz%import runpy; runpy.run_module('ham')r4  r0  r   r1  r   r!   r[   r8   r8   r9   "test_pymain_run_command_run_module1  s   

z+TestExit.test_pymain_run_command_run_modulec                 C   r:  )Nr;  
import hamr4  r<  r[   r8   r8   r9   test_pymain_run_command7  s   z TestExit.test_pymain_run_commandc                 C   s   | j tjgd| jjd d S )Nr>  )inputr5  r<  r[   r8   r8   r9   test_pymain_run_stdin:  s   zTestExit.test_pymain_run_stdinc                 C   s$   | j }| jtjd|jg|jd d S )Nz-mr4  )r   r0  r   r1  stemr!   )r2   r   r8   r8   r9   test_pymain_run_module=  s   zTestExit.test_pymain_run_module)r   rB   rC   ZSTATUS_CONTROL_C_EXITr   platformsignalSIGINTr.  staticmethod
contextlibcontextmanagerr  r%  r0  r2  r7  r9  r=  r?  rA  rC  __classcell__r8   r8   r'  r9   r    s$    
r  r   )0rH  importlib.machineryrQ   importlib.utilZos.pathr_   r   r  r   rE  r+  r   rr   r"  Zunittestr   Ztest.supportr   r   Ztest.support.import_helperr   r   r   Ztest.support.os_helperr   r   Ztest.support.script_helperr	   r
   r   r   r   r   r   rF   Zimplicit_namespacer=   dictrJ   rK   r   ZTestCaserD   rV   r   r  r   mainr8   r8   r8   r9   <module>   sd   	

O'    %M