ó p®¸Qc@s/dZddlZddlZddlZddlZddlZddlZddlmZddl Z ddl m Z ddl m Z mZmZmZmZddlmZd„Zdefd „ƒYZd efd „ƒYZd dd „ƒYZdefd„ƒYZd„Zd„Zd„ZdS(s&Support code for distutils test cases.iÿÿÿÿN(tdeepcopy(tlog(tDEBUGtINFOtWARNtERRORtFATAL(t Distributioncs‡fd†}|S(Ncs1tjƒtjdƒˆ||ŽSWdQXdS(Ntignore(twarningstcatch_warningst simplefilter(targstkw(tfunc(s-/sys/lib/python2.7/distutils/tests/support.pyt_capture_warningss  ((RR((Rs-/sys/lib/python2.7/distutils/tests/support.pytcapture_warningsstLoggingSilencercBs5eZd„Zd„Zd„Zd„Zd„ZRS(cCsStt|ƒjƒtjtjƒ|_tjj|_ |jtj_g|_ dS(N( tsuperRtsetUpRt set_thresholdRt thresholdtLogt_logt_old_logtlogs(tself((s-/sys/lib/python2.7/distutils/tests/support.pyRs cCs6tj|jƒ|jtj_tt|ƒjƒdS(N( RRRRRRRRttearDown(R((s-/sys/lib/python2.7/distutils/tests/support.pyR$scCsQ|tttttfkr4tdt|ƒƒ‚n|jj|||fƒdS(Ns%s wrong log level( RRRRRt ValueErrortstrRtappend(RtleveltmsgR ((s-/sys/lib/python2.7/distutils/tests/support.pyR)scGsAd„}g|jD]*\}}}||kr|||ƒ^qS(NcSst|ƒdkr|S||S(Ni(tlen(R R ((s-/sys/lib/python2.7/distutils/tests/support.pyt_format/s(R(RtlevelsR"RR R ((s-/sys/lib/python2.7/distutils/tests/support.pytget_logs.s cCs g|_dS(N(R(R((s-/sys/lib/python2.7/distutils/tests/support.pyt clear_logs6s(t__name__t __module__RRRR$R%(((s-/sys/lib/python2.7/distutils/tests/support.pyRs    tTempdirManagercBsAeZdZd„Zd„Zd„Zdd„Zdd„ZRS(s}Mix-in class that handles temporary directories for test cases. This is intended to be used with unittest.TestCase. cCs/tt|ƒjƒtjƒ|_g|_dS(N(RR(Rtostgetcwdtold_cwdttempdirs(R((s-/sys/lib/python2.7/distutils/tests/support.pyR@scCs_tj|jƒtt|ƒjƒx5|jrZ|jjƒ}tj |tj dkƒq&WdS(Ntnttcygwin(sntscygwin( R)tchdirR+RR(RR,tpoptshutiltrmtreetname(Rtd((s-/sys/lib/python2.7/distutils/tests/support.pyREs  cCs tjƒ}|jj|ƒ|S(sjCreate a temporary directory that will be cleaned up. Returns the path of the directory. (ttempfiletmkdtempR,R(RR4((s-/sys/lib/python2.7/distutils/tests/support.pyR6Ns txxxcCs\t|ttfƒr*tjj|Œ}nt|dƒ}z|j|ƒWd|jƒXdS(sWWrites a file in the given path. path can be a string or a sequence. twN( t isinstancetlistttupleR)tpathtjointopentwritetclose(RR<tcontenttf((s-/sys/lib/python2.7/distutils/tests/support.pyt write_fileWs tfoocKsG|jƒ}tjj||ƒ}tj|ƒtd|ƒ}||fS(sWill generate a test environment. This function creates: - a Distribution instance using keywords - a temporary directory with a package structure It returns the package directory and the distribution instance. tattrs(R6R)R<R=tmkdirR(Rtpkg_nameR ttmp_dirtpkg_dirtdist((s-/sys/lib/python2.7/distutils/tests/support.pyt create_distes  (R&R't__doc__RRR6RCRK(((s-/sys/lib/python2.7/distutils/tests/support.pyR(:s   t DummyCommandcBs eZdZd„Zd„ZRS(sAClass to store options for retrieval via set_undefined_options().cKs1x*|jƒD]\}}t|||ƒq WdS(N(titemstsetattr(RtkwargsR tval((s-/sys/lib/python2.7/distutils/tests/support.pyt__init__zscCsdS(N((R((s-/sys/lib/python2.7/distutils/tests/support.pytensure_finalized~s(R&R'RLRRRS(((s-/sys/lib/python2.7/distutils/tests/support.pyRMws t EnvironGuardcBseZd„Zd„ZRS(cCs)tt|ƒjƒttjƒ|_dS(N(RRTRRR)tenviront old_environ(R((s-/sys/lib/python2.7/distutils/tests/support.pyR„scCs•xE|jjƒD]4\}}tjj|ƒ|kr|tj|cannot find xxmodule.c (test must run in the python build dir)N(t_get_xxmodule_pathtNonetunittesttSkipTestR1tcopy(t directorytfilename((s-/sys/lib/python2.7/distutils/tests/support.pytcopy_xxmodule_c”s  c Cs‘tjdƒ}tjjtjjtƒdƒtjj|ddƒtjj|dddddƒg}x$|D]}tjj|ƒrm|SqmWdS(Ntsrcdirs xxmodule.ctModuless..(t sysconfigtget_config_varR)R<R=tdirnamet__file__texists(Rct candidatesR<((s-/sys/lib/python2.7/distutils/tests/support.pyR[§s$ cCs¯tjdkr'tjjdƒ|_n„tjdƒr«tjdƒ}|dkr`dg|_ q«tj dkr{g|_ q«|j dƒ\}}}|j tj ƒ|_ ndS( s4Function needed to make build_ext tests pass. When Python was build with --enable-shared on Unix, -L. is not good enough to find the libpython.so. This is because regrtest runs it under a tempdir, not in the top level where the .so lives. By the time we've gotten here, Python's already been chdir'd to the tempdir. When Python was built with in debug mode on Windows, build_ext commands need their debug attribute set, and it is not done automatically for some reason. This function handles both of these things. Example use: cmd = build_ext(dist) support.fixup_build_ext(cmd) cmd.ensure_finalized() Unlike most other Unix platforms, Mac OS X embeds absolute paths to shared libraries into executables, so the fixup is not needed there. R-s_d.exetPy_ENABLE_SHAREDt RUNSHAREDt.tdarwint=N(R)R3tsyst executabletendswithtdebugReRfR\t library_dirstplatformt partitiontsplittpathsep(tcmdt runsharedR3tequalsRZ((s-/sys/lib/python2.7/distutils/tests/support.pytfixup_build_extºs  ((RLR)RpR1R5R]ReR_RR t distutilsRt distutils.logRRRRRtdistutils.coreRRtobjectRR(RMRTRbR[R|(((s-/sys/lib/python2.7/distutils/tests/support.pyts&       ( "=