tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
R\¬Qc@s"ddlZddlZddlZddlZddlZddlZddlmZmZm    Z    ddl
m Z m Z m Z mZmZmZddlmZmZmZmZdejfd„ƒYZdejfd„ƒYZd    ejfd
„ƒYZd „Zed kreƒndS( iÿÿÿÿN(tverboset run_unittesttforget(ttemp_dirt make_scripttcompile_scripttmake_pkgtmake_zip_scriptt make_zip_pkg(t    _run_codet_run_module_codet
run_moduletrun_pathtRunModuleCodeTestcBs2eZdZddgZdZd„Zd„ZRS(s9Unit tests for runpy._run_code and runpy._run_module_codesTop level assignmentsLower level references§# Check basic code execution
result = ['Top level assignment']
def f():
    result.append('Lower level reference')
f()
# Check the sys module
import sys
run_argv0 = sys.argv[0]
run_name_in_sys_modules = __name__ in sys.modules
if run_name_in_sys_modules:
   module_in_sys_modules = globals() is sys.modules[__name__].__dict__
# Check nested operation
import runpy
nested = runpy._run_module_code('x=1\n', mod_name='<run>')
cCsÅtjd}t|jiƒ}|j|d|jƒ|j|ddƒ|j|ddƒ|j|ddƒ|j|ddƒ|j|d|ƒ|jd|ƒ|jtjd|ƒdS(    Nitresultt__name__t__file__t
__loader__t __package__t    run_argv0trun_name(    tsystargvR    t test_sourcet assertEqualtexpected_resulttassertIstNonet assertNotIn(tselft saved_argv0td((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt test_run_code*s c    Csbtƒ}d}d}d}d}td|ƒ}tjd}t|j|||||ƒ}|jd|ƒ|j|d|ƒ|j|d|j    ƒ|j|dd    d
ƒ|j|d |ƒ|j
|d ƒ|j
|d ƒ|j|d|ƒ|j|d|ƒ|j|d|ƒ|j|d|ƒ|jtjd|ƒ|j|tj ƒdS(Ns
<Nonsense>sSome other nonsensesNow you're just being sillyttinitialiRtnestedtxiRtrun_name_in_sys_modulestmodule_in_sys_modulesRRRR( tobjecttdictRRR
RRRRRt
assertTruetmodules(    RR"tnametfiletloadertpackagetd1Rtd2((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_run_module_code6s4             (Rt
__module__t__doc__RRR R1(((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyR s
      t RunModuleTestcBs’eZdZd„Zd„Zd„Zd„Zdd„Zd„Zd„Z    d    „Z
d
„Z dd „Z d „Zd „Zd„Zd„ZRS(sUnit tests for runpy.run_modulecCs7yt|ƒWntk
r!nX|jd|ƒdS(NsExpected import error for (R t ImportErrortfail(Rtmod_name((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pytexpect_import_errorVs
 cCs_|jdƒ|jdƒ|jdƒ|jdƒ|jdƒ|jdƒ|jdƒdS(NRs sys.imp.erics os.path.halfsa.bees.howards..eatentmultiprocessing(R8(R((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_invalid_names^s      cCstdƒdS(Ntrunpy(R (R((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_library_modulejscCsJtj|ƒtjj|dtjdƒ}t|dƒ}|jƒ|S(Nt__init__tpytw(tostmkdirtpathtjointextseptopentclose(Rtpkg_dirt    pkg_fnametpkg_file((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt _add_pkg_dirms
  
t
runpy_testc Cs0d}|tjd}tjƒ}}tr9dG|GHntjjd|ƒtredGtjdGHnx\t|ƒD]N}tjj    ||ƒ}|j
|ƒ}    tr®dG|GHntrrdG|    GHqrqrWtjj    ||ƒ}
t |
dƒ} | j |ƒ| j ƒtrdG|
GHn|d    ||} ||
| fS(
Nt __runpy_pkg__R>s  Package tree in:is  Updated sys.path:s  Next level in:s
  Created:R?t.(R@RDttempfiletmkdtempRRRBtinserttrangeRCRJREtwriteRF( Rtsourcetdepthtmod_basetpkg_namet
test_fnameRGtsub_dirtiRHt    mod_fnametmod_fileR7((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt    _make_pkgts.   
 c Cs|x3ttjƒD]"}|jdƒrtj|=qqWtrDdGHntjd=tr\dGHnxÖtj|dtƒD]¿\}}}xR|D]J}y tj    tjj
||ƒƒWqˆt k
rÑ}    trÒ|    GHqÒqˆXqˆWxX|D]P}tjj
||ƒ}
ytj |
ƒWqÝt k
r,}    tr-|    GHq-qÝXqÝWqrWytj |ƒtrSdGHnWn!t k
rw}    trx|    GHqxnXdS(NRLs  Removed sys.modules entriesis  Removed sys.path entryttopdowns  Removed package tree( tlistRR*t
startswithRRBR@twalktFalsetremoveRCtOSErrortrmdir( RttopRTR7tentrytroottdirstfilesR+textfullname((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt_del_pkgˆs:
%     cCs|jd|ƒ\}}}t|ƒz·tr:dG|GHnt|ƒ}|jd|ƒ|j|ddkƒ~t|ƒtj|ƒt    j
sÛtr¢dG|GHnt|ƒ}|jd|ƒ|j|ddkƒ~nWd|j |||ƒXtrdGHndS(Nsx=1
sRunning from source:R$isRunning from compiled:sModule executed successfully( R\RRR tassertInR)t
__import__R@RbRtdont_write_bytecodeRl(RRTRGRZR7R/R0((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt _check_module¡s*
 
       
c    Cs |jd|dƒ\}}}|jdƒ\}}}t|ƒz·trUdG|GHnt|ƒ}|jd|ƒ|j|ddkƒ~t|ƒtj    |ƒt
j sötr½dG|GHnt|ƒ}|jd|ƒ|j|ddkƒ~nWd|j |||ƒXtrdGHndS(    Nsx=1
t__main__RMsRunning from source:R$isRunning from compiled:sPackage executed successfully( R\t
rpartitionRRR RmR)RnR@RbRRoRl(    RRTRGRZR7RVt_R/R0((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt_check_package·s,
 
       
cCs[|dkrtdƒ‚nd}|}x/t|ƒD]!}|}tjj||ƒ}q4Wtjj|dtjdƒ}t|dƒ}    |    jƒtr¤dG|GHntjj|dƒ}
|j    |
ƒtrØd    G|
GHntjj|
d
ƒ} |j    | ƒtr d G| GHntjj| d tjdƒ} t| dƒ} | jƒtrWd G| GHndS(Nis$Relative module test needs depth > 1RLtsiblingR>R?s  Added sibling module:tuncles  Added uncle package:tcousins  Added cousin package:tnephews  Added nephew module:(
t
ValueErrorRQR@RBRCRDRERFRRJ(Rtbase_dirRSRTRVt
module_dirRYt
parent_dirt sibling_fnamet sibling_filet    uncle_dirt
cousin_dirt nephew_fnamet nephew_file((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt_add_relative_modulesÎs2  
      
c
Cssd}|j||ƒ\}}}z)|j|||ƒ|jdƒd}tr\dG|GHnt|d|ƒ}|jd|ƒ|j|d|kƒ|jd|ƒ|jd|ƒ~t|ƒtj    |ƒt
j sItrêd    G|GHnt|d|ƒ}    |jd|    ƒ|j|    d|kƒ|jd|    ƒ|jd|    ƒ~    nWd|j |||ƒXtrod
GHndS( Nsa\
from __future__ import absolute_import
from . import sibling
from ..uncle.cousin import nephew
RMisRunning from source:RRRuRxsRunning from compiled:sModule executed successfully( R\RƒRrRR RmR)RnR@RbRRoRl(
RRTRtcontentsRGRZR7RVR/R0((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt_check_relative_importsçs6 
      
cCs:x3tdƒD]%}tr%dG|GHn|j|ƒq WdS(NisTesting package depth:(RQRRp(RRT((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_run_modules cCs=x6tddƒD]%}tr(dG|GHn|j|ƒqWdS(NiisTesting package depth:(RQRRt(RRT((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_run_package s cCs=x6tddƒD]%}tr(dG|GHn|j|ƒqWdS(Niis"Testing relative imports at depth:(RQRR…(RRT((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_explicit_relative_imports cCs@x9tddƒD](}tr(dG|GHn|j|dƒqWdS(Niis'Testing main relative imports at depth:Rq(RQRR…(RRT((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_main_relative_imports N(RR2R3R8R:R<RJR\RlRpRtRƒRR…R†R‡RˆR‰(((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyR4Ss                                               t RunPathTestcBsƒeZdZdZdd„Zd„Zd„Zd„Zd„Z    d„Z
d„Z d    „Z d
„Z d „Zd „Zd „ZRS(sUnit tests for runpy.run_pathsX# Script may be run with optimisation enabled, so don't rely on assert
# statements being executed
def assertEqual(lhs, rhs):
    if lhs != rhs:
        raise AssertionError('%r != %r' % (lhs, rhs))
def assertIs(lhs, rhs):
    if lhs is not rhs:
        raise AssertionError('%r is not %r' % (lhs, rhs))
# Check basic code execution
result = ['Top level assignment']
def f():
    result.append('Lower level reference')
f()
assertEqual(result, ['Top level assignment', 'Lower level reference'])
# Check the sys module
import sys
assertIs(globals(), sys.modules[__name__].__dict__)
argv0 = sys.argv[0]
cCs(|dkr|j}nt|||ƒS(N(RRR(Rt
script_dirtscript_basenameRS((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt_make_test_script5s  cCspt|ƒ}|j|d|ƒ|j|d|ƒ|jd|ƒ|j|d|ƒ|j|d|ƒdS(NRRtargv0R(R RRm(Rt script_namet expected_namet expected_filetexpected_argv0texpected_packageR((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt _check_script:s  cCs)tj|ƒ}|jt|t|ƒdS(N(tretescapetassertRaisesRegexpR5R (RRtmsg((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt_check_import_errorCsc
CsGtƒ8}d}|j||ƒ}|j|d||dƒWdQXdS(Ntscripts
<run_path>(RRR”R(RR‹R7R((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_basic_scriptGs
 c
Cs`tƒQ}d}|j||ƒ}t|ƒ}tj|ƒ|j|d||dƒWdQXdS(NRšs
<run_path>(RRRR@RbR”R(RR‹R7Rt compiled_name((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_script_compiledNs   c
CsGtƒ8}d}|j||ƒ}|j|d||dƒWdQXdS(NRqs
<run_path>R!(RRR”(RR‹R7R((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_directoryWs
 c
Cs`tƒQ}d}|j||ƒ}t|ƒ}tj|ƒ|j|d||dƒWdQXdS(NRqs
<run_path>R!(RRRR@RbR”(RR‹R7RRœ((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_directory_compiled^s   cCsHtƒ9}d}|j||ƒ}d|}|j||ƒWdQXdS(Ntnot_mains"can't find '__main__' module in %r(RRR™(RR‹R7RR˜((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_directory_errorgs
 
c
Cs_tƒP}d}|j||ƒ}t|d|ƒ\}}|j|d||dƒWdQXdS(NRqttest_zips
<run_path>R!(RRRR”(RR‹R7Rtzip_nametfname((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt test_zipfilens
 c
Csktƒ\}d}|j||ƒ}t|ƒ}t|d|ƒ\}}|j|d||dƒWdQXdS(NRqR¢s
<run_path>R!(RRRRR”(RR‹R7RRœR£R¤((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_zipfile_compiledus   cCs`tƒQ}d}|j||ƒ}t|d|ƒ\}}d|}|j||ƒWdQXdS(NR R¢s"can't find '__main__' module in %r(RRRR™(RR‹R7RR£R¤R˜((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_zipfile_error}s  
c     Cstƒr}tƒ`}d}d|}|j|||ƒ}t|d|ƒ\}}d}|jt|t|ƒWdQXWdQXdS(NRqs import runpy
runpy.run_path(%r)
R¢srecursion depth exceeded(RRRR—t RuntimeErrorR (    RR‹t    dummy_dirR7RSRR£R¤R˜((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyttest_main_recursion_error…s N(RR2R3RRRR”R™R›RRžRŸR¡R¥R¦R§Rª(((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyRŠs                                                     cCsttttƒdS(N(RR R4RŠ(((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt    test_main‘sRq(tunittestR@tos.pathRR•RNttest.test_supportRRRttest.script_helperRRRRRRR;R    R
R R tTestCaseR R4RŠR«R(((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_runpy.pyt<module>s      .">Éu