ķ {G_Tc@s”ddlZddlZddlZddlZddlZddlZddlmZdejfd„ƒYZ d„Z e dkre ƒndS(i˙˙˙˙N(t run_unittestt TestImportcBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cOsgd|_x1|jtjkr<|jtjtjƒ7_q W|jd|_tj j |||ŽdS(NtPACKAGE_s.foo( t package_nametsystmodulestrandomtchoosetstringtletterst module_nametunittesttTestCaset__init__(tselftargstkw((s//usr/local/lib/python2.7/test/test_pkgimport.pyR s  cCs=x6|j|jfD]"}|tjkrtj|=qqWdS(N(RR RR(RR ((s//usr/local/lib/python2.7/test/test_pkgimport.pytremove_modulesscCsĒtjƒ|_tjj|jƒtjj|j|jƒ|_ tj |j ƒt tjj|j dtj dƒdƒj ƒtjj|j dtj dƒ|_dS(NR tpytwtfoo(ttempfiletmkdtempttest_dirRtpathtappendtostjoinRt package_dirtmkdirtopentextseptcloset module_path(R((s//usr/local/lib/python2.7/test/test_pkgimport.pytsetUps $cCsœx9tj|jƒD]%}tjtjj|j|ƒƒqWtj|jƒtj|jƒ|jt jj |jƒdƒt jj|jƒ|j ƒdS(Ni( RtlistdirRtremoveRRtrmdirRtassertNotEqualRtcountR(Rtfile((s//usr/local/lib/python2.7/test/test_pkgimport.pyttearDowns#cCsmx=dD]5}|j|}tjj|ƒrtj|ƒqqWt|jdƒ}|j|ƒ|jƒdS(NtcoR(R!RRtexistsR$RtwriteR (Rtcontentst extensiont compiled_pathtf((s//usr/local/lib/python2.7/test/test_pkgimport.pyt rewrite_file&s   cCs!|jdƒyt|jƒWntk r1n Xtd‚|j|jtjƒ|jt tj|j dƒƒd}x,|t t ƒkrĨ|t jtjƒ7}qzW|j|ƒyt|jƒWntk r×n Xtd‚|jd|ƒt|jƒj}|jt||ƒdƒdS(NtforsFailed to induce SyntaxErrorRtasFailed to induce NameError.s%s = 1i(R1t __import__R t SyntaxErrort RuntimeErrort assertNotInRRt assertFalsethasattrRtdirt __builtins__RRRR t NameErrorRt assertEqualtgetattr(Rtvartmodule((s//usr/local/lib/python2.7/test/test_pkgimport.pyttest_package_import__semantics/s(       (t__name__t __module__R RR"R)R1RA(((s//usr/local/lib/python2.7/test/test_pkgimport.pyRs    cCsttƒdS(N(RR(((s//usr/local/lib/python2.7/test/test_pkgimport.pyt test_mainNst__main__( RRRRRR ttest.test_supportRR RRDRB(((s//usr/local/lib/python2.7/test/test_pkgimport.pyts HI