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
R\¬Qc@s|dZddlZddlmZmZmZddlmZddlZddlZddl    Z    ddl
Z
ddl Z ddl Z ddl Z ddlmZde    jkrÀddlZnejdƒ‚ejrejjejƒ rejejƒejejƒndejfd    „ƒYZd
efd „ƒYZd ejfd „ƒYZd„ZedkrxeƒndS(sTests for 'site'.
 
Tests assume the initial paths in sys.path once the interpreter has begun
executing have not been removed.
 
iÿÿÿÿN(t run_unittesttTESTFNtEnvironmentVarGuard(tcaptured_output(tcopytsites!importation of site.py suppressedtHelperFunctionsTestscBsËeZdZd„Zd„Zd„Zd„Zd„Zd„Zde    d„Z
d    „Z d
„Z e jejd kd ƒd „ƒZd„Ze jejdƒd„ƒZd„Zd„Zd„ZRS(s›Tests for helper functions.
 
    The setting of the encoding (set using sys.setdefaultencoding) used by
    the Unicode implementation is not tested.
 
    cCsGtj|_tj|_tj|_tj|_    t
t j ƒ|_ dS(sSave a copy of sys.pathN(tsystpathtsys_pathRt    USER_BASEtold_baset    USER_SITEtold_sitetPREFIXESt old_prefixesRt    sysconfigt _CONFIG_VARStold_vars(tself((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pytsetUp(s
    cCsA|jtj(|jt_|jt_|jt_    |j
t _ dS(sRestore sys.pathN( R    RRR RR
R R RRRRR(R((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttearDown0s
    cCs”d}tjj|Œ}tj|Œ\}}|jtjj|ƒ|ƒ|tjj|ƒkrt|j||ƒn|jtjj|ƒ|ƒdS(Nt    BeginningtEnd(RR(tosRtjoinRtmakepatht assertEqualtabspathtnormcase(Rt
path_partst original_dirtabs_dirtnorm_dir((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyt test_makepath8scCsytjƒ}xfgtjD]1}|rtjj|ƒrtj|ƒd^qD]#}|j||d||fƒqNWdS(NisB%s from sys.path not found in set returned by _init_pathinfo(): %s(Rt_init_pathinfoRRRtisdirRtassertIn(Rtdir_setRtentry((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_init_pathinfoEs  5 cCsc|j|jtjd|jƒ|jtj|jƒdtjƒ|jt    jj
|j ƒƒdS(s>Contain common code for testing results of reading a .pth files%s not in sys.modulesiN( R%timportedRtmodulesRRt good_dir_pathRt assertFalseRtexistst bad_dir_path(Rtpth_file((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pytpth_file_testsMs#cCsbtƒ}|jdtƒz7|jƒtj|j|jtƒƒ|j    |ƒWd|jƒXdS(Ntprep(
tPthFiletcleanuptTruetcreateRt
addpackagetbase_dirtfilenametsetR0(RR/((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_addpackageTs    
t.cswtjj|ƒ}|d}tjj||ƒ‰tˆdƒ}|j‡fd†ƒ|j|ƒ|jƒ||fS(Ns.pthtwcs tjˆƒS(N(Rtremove((tpth_fn(sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyt<lambda>is(RRRRtopent
addCleanuptwritetclose(Rtcontentstpth_dirtpth_namet pth_basenameR/((R>sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pytmake_pthcs
 
cCsÊ|jdƒ\}}tdƒ}tj||tƒƒWdQX|j|jƒdƒ|j|jƒtjt    j
j ||ƒƒƒ|j|jƒdƒ|j|jƒdƒ|j|jƒdƒdS(Nsimport bad)syntax
tstderrsline 1t    Tracebacksimport bad\)syntaxt SyntaxError( RHRRR6R9tassertRegexpMatchestgetvaluetretescapeRRR(RRER>terr_out((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyt!test_addpackage_import_bad_syntaxnscCs´|jdƒ\}}tdƒ}tj||tƒƒWdQX|j|jƒdƒ|j|jƒtjt    j
j ||ƒƒƒ|j|jƒdƒ|j|jƒdƒdS(Nsrandompath
import nosuchmodule
RIsline 2RJt ImportError( RHRRR6R9RLRMRNRORRR(RRER>RP((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_addpackage_import_bad_exec}stwin32sIWindows does not raise an error for file paths containing null characterscCs´|jdƒ\}}tdƒ}tj||tƒƒWdQX|j|jƒdƒ|j|jƒtjt    j
j ||ƒƒƒ|j|jƒdƒ|j|jƒdƒdS(Ntabcdef
RIsline 1RJt    TypeError( RHRRR6R9RLRMRNRORRR(RRER>RP((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyt#test_addpackage_import_bad_pth_file‰scCs\tƒ}|jdtƒz1|jƒtj|jtƒƒ|j|ƒWd|jƒXdS(NR1(    R2R3R4R5Rt
addsitedirR7R9R0(RR/((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_addsitedir—s    
s<requires access to PEP 370 user-site (site.ENABLE_USER_SITE)cCsPtj}|j|tjƒtjjƒ}tj    tj
dd|gd|ƒ}|j |dd||fƒtjjƒ}tj    tj
ddd|gd|ƒ}|j |dƒtjjƒ}d|d    <tj    tj
dd|gd|ƒ}|j |dƒtjjƒ}d
|d <tj    tj
dd gd|ƒ}|j |dƒdS( Ns-cs$import sys; sys.exit(%r in sys.path)tenvis,%r is not in sys.path (sys.exit returned %r)s-sit1tPYTHONNOUSERSITEs/tmptPYTHONUSERBASEs=import sys, site; sys.exit(site.USER_BASE.startswith("/tmp"))( RR R%RRRtenvironRt
subprocesstcallt
executableR(RtusersiteRZtrc((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyt test_s_option¤s2              
     
        cCs‹dt_tjƒ}|jtj|ƒdt_ddl}d|_tƒ6}d|d<|jtjƒj    dƒtjƒƒWdQXdS(NiÿÿÿÿtxoxoR](
tNoneRR
t getuserbaseRRRRt
assertTruet
startswith(Rt    user_baseRR^((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_getuserbaseÅs               
cCsQdt_dt_tjƒ}|jtj|ƒ|j|jtjƒ|ƒdS(N(RfRR R
tgetusersitepackagesRRhRi(Rt    user_site((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_getusersitepackagesÖs
         cCsâdgt_tjƒ}tjdkrl|jt|ƒdƒtjj    dddƒ}|j|d|ƒnrtjdkrút
j d    ƒrúd
gt_tjƒ}|jt|ƒd ƒtjj    d t
j d    ƒtj d  dƒ}|j|d |ƒnätj dkrˆ|jt|ƒd ƒtjj    dddtj d  dƒ}|j|d|ƒtjj    dddƒ}|j|d|ƒnV|jt|ƒd ƒ|j|ddƒtjj    dddƒ}|j|d|ƒdS(NRetos2emxtriscositLibs site-packagesitdarwintPYTHONFRAMEWORKsPython.frameworkis/Libraryit/tlibtpythons site-python(sos2emxsriscos(RRtgetsitepackagesRtplatformRtlenRRRRtget_config_vartversiontsep(Rtdirstwanted((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_getsitepackagesßs6      
        (t__name__t
__module__t__doc__RRR"R(R0R:RRHRQRStunittesttskipIfRRxRWRYt
skipUnlessRtENABLE_USER_SITERdRkRnR(((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyR s                                  $     !            R2cBs8eZdZedddd„Zd„Zed„ZRS(s/Helper class for handling testing of .pth filesttimet __testdir__t__badcCs›|d|_tjjdƒ|_tjj|j|jƒ|_||_||_||_    tjj|j|jƒ|_
tjj|j|j    ƒ|_ dS(sInitialize instance variabless.pthtN( R8RRRR7Rt    file_pathR)t good_dirnamet bad_dirnameR+R.(Rt filename_baseR)RŒR((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyt__init__s             cCswt|jdƒ}zC|dIJ|dIJ|d|jIJ||jIJ||jIJWd|jƒXtj|jƒdS(soCreate 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.
 
        R<s#import @bad module names
s    import %sN(    R@R‹R)RŒRRCRtmkdirR+(RtFILE((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyR5s 
 
  cCsÕtjj|jƒr(tj|jƒn|rbtjj|jƒ|_    |j    rtj|j=qn|j    r|j    tj|j<ntjj|j
ƒr©tj |j
ƒntjj|j ƒrÑtj |j ƒndS(s°Make 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( RRR-R‹R=RR*tgetR)timported_moduleR+trmdirR.(RR1((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyR3&s        (R€RR‚RRR5tFalseR3(((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyR2s
    tImportSideEffectTestscBsqeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z    d„Z
d    „Z d
„Z d „Z RS( s(Test side-effects from importing 'site'.cCstj|_dS(sMake a copy of sys.pathN(RRR    (R((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyR;scCs|jtj(dS(sRestore sys.pathN(R    RR(R((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyR?scCshtjƒxWtttfD]F}y)|jtjj|jƒt    |ƒƒWqt
k
r_qqXqWdS(N( Rt abs__file__RRt __builtin__RhRtisabst__file__treprtAttributeError(Rtmodule((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_abs__file__Cs 
) cCsHtjƒtƒ}x.tjD]#}|j||ƒ|j|ƒqWdS(N(RtremoveduppathsR9RRt assertNotIntadd(Rt
seen_pathsR((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_no_duplicate_pathsQs
 
    cCsdS(N((R((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_add_build_dirZscCs0|jttdƒƒ|jttdƒƒdS(Ntquittexit(RhthasattrR˜(R((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_setting_quit`scCs0|jttdƒƒ|jttdƒƒdS(Nt    copyrighttcredits(RhR§R˜(R((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_setting_copyrightescCs|jttdƒƒdS(Nthelp(RhR§R˜(R((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_setting_helpjscCsxtjdkrtddl}|jƒdjdƒrtx:tjjjƒD]}|dkrGPqGqGW|jdƒqtndS(NRTiÿÿÿÿitcptmbcssdid not alias mbcs(    RRxtlocaletgetdefaultlocaleRit    encodingstaliasest
itervaluestfail(RR°tvalue((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_aliasing_mbcsns  cCs|jttdƒ ƒdS(Ntsetdefaultencoding(RhR§R(R((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_setdefaultencoding_removedxscCsGdtjkrCyddl}Wntk
r2qCX|jdƒndS(Nt sitecustomizeiÿÿÿÿs(sitecustomize not imported automatically(RR*RºRRRµ(RRº((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyttest_sitecustomize_executed|s  (R€RR‚RRRžR£R¤R¨R«R­R·R¹R»(((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyR–8s                                        
   cCstttƒdS(N(RRR–(((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyt    test_main†st__main__(R‚Rƒttest.test_supportRRRRR˜RRRNR²R_RRR*RtSkipTestR†RR$R tmakedirsRXtTestCaseRtobjectR2R–R¼R€(((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_site.pyt<module>s.        á7N