:o q'dZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZmZmZmZmZddlmZGdd eZGd d eZGd d ZGddeZdZdZdZdS)z&Support code for distutils test cases.N)deepcopy) os_helper)log)DEBUGINFOWARNERRORFATAL) Distributionc:eZdZfdZfdZdZdZdZxZS)LoggingSilencercttjtj|_tjj|_|jtj_g|_ dSN) supersetUpr set_thresholdr thresholdLog_log_old_loglogsself __class__s >/opt/alt/python311/lib64/python3.11/distutils/tests/support.pyrzLoggingSilencer.setUpsK  *3955  y  ctj|j|jtj_t dSr)rrrrrrrtearDownrs rrzLoggingSilencer.tearDowns= $.)))}  rc4|tttttfvrt dt |zt|t s$tdt|j z|j |||fdS)Nz%s wrong log levelzmsg should be str, not '%.200s') rrrr r ValueErrorstr isinstance TypeErrortype__name__rappend)rlevelmsgargss rrzLoggingSilencer._log!s dE59 9 91CJJ>?? ?#s## 4=#Cyy1344 4 %d+,,,,,rc*fd|jDS)Nc*g|]\}}}|v ||zSr,).0r'r(r)levelss r z,LoggingSilencer.get_logs..*s4111/uc4 %d /rr)rr.s `rget_logszLoggingSilencer.get_logs)s011119111 1rcg|_dSrr0rs r clear_logszLoggingSilencer.clear_logs-s  r) r% __module__ __qualname__rrrr1r4 __classcell__rs@rr r s~ ---111rr cBeZdZdZfdZfdZdZd dZd dZxZ S) TempdirManagerz}Mix-in class that handles temporary directories for test cases. This is intended to be used with unittest.TestCase. cttj|_g|_dSr)rrosgetcwdold_cwdtempdirsrs rrzTempdirManager.setUp7s,  y{{  rctj|jt|jr6|j}tj||j4dSdSr) r<chdirr>rrr?poprrmtree)rtmpdirrs rrzTempdirManager.tearDown<s{  m %]&&((F  V $ $ $m % % % % %rc`tj}|j||S)zjCreate a temporary directory that will be cleaned up. Returns the path of the directory. )tempfilemkdtempr?r&)rds rrGzTempdirManager.mkdtempEs-     Qrxxxc t|ttfrtjj|}t |d} |||dS#|wxYw)zWWrites a file in the given path. path can be a string or a sequence. wN) r"listtupler<pathjoinopenwriteclose)rrNcontentfs r write_filezTempdirManager.write_fileNso dT5M * * '7<&D sOO  GGG    GGIIIIIAGGIIIIs A,,Bfooc |}tj||}tj|t |}||fS)aWill 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. )attrs)rGr<rNrOmkdirr )rpkg_namekwtmp_dirpkg_dirdists r create_distzTempdirManager.create_dist\sP,,..',,w11 "%%%}r)rI)rV) r%r5r6__doc__rrrGrUr_r7r8s@rr:r:1s  %%%%%    rr:ceZdZdZdZdZdS) DummyCommandzAClass to store options for retrieval via set_undefined_options().c \|D]\}}t|||dSr)itemssetattr)rkwargsr[vals r__init__zDummyCommand.__init__qs<||~~ # #GB D"c " " " " # #rcdSrr,r3s rensure_finalizedzDummyCommand.ensure_finalizedus rN)r%r5r6r`rhrjr,rrrbrbns8KK###     rrbc(eZdZfdZfdZxZS) EnvironGuardctt|ttj|_dSr)rrlrrr<environ old_environrs rrzEnvironGuard.setUp{s7 lD!!'')))#BJ//rc|jD]7\}}tj||kr|tj|<8t tjD]}||jvr tj|=tt| dSr) rordr<rngetrMkeysrrlr)rkeyvaluers rrzEnvironGuard.tearDowns*0022 ( (JCz~~c""e++"' 3**++ $ $C$***JsO lD!!**,,,,,r)r%r5r6rrr7r8s@rrlrlysQ00000 - - - - - - - - -rrlcxt}|tjdtj||dS)akHelper for tests that need the xxmodule.c source file. Example use: def test_compile(self): copy_xxmodule_c(self.tmpdir) self.assertIn('xxmodule.c', os.listdir(self.tmpdir)) If the source file can be found, it will be copied to *directory*. If not, the test will be skipped. Errors during copy are not caught. Nz>cannot find xxmodule.c (test must run in the python build dir))_get_xxmodule_pathunittestSkipTestshutilcopy) directoryfilenames rcopy_xxmodule_cr}sG"##H!899 9 K)$$$$$rc tjd}tjtjt dtj|ddtj|dddddg}|D]%}tj|r|cS&dS)Nsrcdirz xxmodule.cModulesz..) sysconfigget_config_varr<rNrOdirname__file__exists)r candidatesrNs rrvrvs  %h / /F  RW__X.. ==  VY 55  VT4y,GG J 7>>$   KKK rctjdkr&tjd|_dSt jdrt jd}| dg|_dStj dkr g|_dS| d\}}}d | tj D|_dSdS) aFunction needed to make build_ext tests pass. When Python was built with --enable-shared on Unix, -L. is not enough to find libpython.so, because regrtest runs in a tempdir, not in the source directory where the .so lives. 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. ntz_d.exePy_ENABLE_SHARED RUNSHAREDN.darwin=cg|]}||Sr,r,)r-rHs rr/z#fixup_build_ext..s#L#L#L!!#LA#L#L#Lr) r<namesys executableendswithdebugrr library_dirsplatform partitionsplitpathsep)cmd runsharedrequalsrts rfixup_build_extrs( w$N++H55  !"4 5 5 M,[99   #uC   |x''#%   &/&9&9#&>&>#fe#L#Lu{{2:/F/F#L#L#L    M Mr)r`r<rryrFrwrrzr test.supportr distutilsr distutils.logrrrr r distutils.corer objectr r:rbrlr}rvrr,rrrs,, """"""99999999999999''''''fB:::::V:::z        -----6---$%%%&""M"M"M"M"Mr