fXldZddlZddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z m Z m Z dZejdejZGdd e jZd Zd Zd Zd ZdZGddeZeZddZe jdfdZde je jfdZ de je jfdZ!dS)zLoading unittests.N)fnmatch fnmatchcase)casesuiteutilTz[_a-z]\w*\.py$c,eZdZdZfdZfdZxZS) _FailedTestNcf||_tt||dSN) _exceptionsuperr __init__)self method_name exception __class__s 6/opt/alt/python311/lib64/python3.11/unittest/loader.pyrz_FailedTest.__init__s.# k4  ))+66666cz|jkr(tt|Sfd}|S)Ncjr )r rsr testFailurez,_FailedTest.__getattr__..testFailure!s / !r)_testMethodNamerr __getattr__)rnamerrs` rrz_FailedTest.__getattr__sO 4' ' 'd++77== = " " " " "r)__name__ __module__ __qualname__rrr __classcell__rs@rr r sVO77777rr crd|dtj}t|t|||S)NzFailed to import test module:  ) traceback format_exc_make_failed_test ImportError)r suiteClassmessages r_make_failed_import_testr*&s< i"$$$&G T;w#7#7W M MMrcRdtj}t||||S)NzFailed to call load_tests: )r$r%r&)rrr(r)s r_make_failed_load_testsr,+s32;2F2H2H2HJG  iW . ..rc>t||}||f|fSr )r ) methodnamerr(r)tests rr&r&0s( z9 - -D :tg   ''rctjt|d}||i}tdtjf|}|||fS)NcdSr rs r testSkippedz'_make_skipped_test..testSkipped5s r ModuleSkipped)rskipstrtypeTestCase)r.rr(r3attrs TestClasss r_make_skipped_testr;4si Ys9~~    %E_t}&6>>I :yy,,. / //rc|dr |ddStj|dS)Nz $py.classir)lowerendswithospathsplitext)r@s r_jython_aware_splitextrB<sI zz||[))CRCy 7  D ! !! $$rceZdZdZdZeejZdZ e j Z dZ fdZdZdddZddZdd Zd Zdd Zd ZdZdZdZdZdZxZS) TestLoaderz This class is responsible for loading tests according to various criteria and returning them wrapped in a TestSuite r/Nctt|g|_t |_dSr )rrDrerrorsset_loading_packages)rrs rrzTestLoader.__init__Ms: j$((*** "%rc,t|tjrtd|tjtjfvrg}n*||}|st|drdg}| t||}|S)z;Return a suite of all test cases contained in testCaseClasszYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?runTest) issubclassr TestSuite TypeErrorrr8FunctionTestCasegetTestCaseNameshasattrr(map)r testCaseClass testCaseNames loaded_suites rloadTestsFromTestCasez TestLoader.loadTestsFromTestCaseTs mU_ 5 5 )()) ) T]D,AB B BMM 11-@@M  ,W]I%F%F ,!* s=-'H'HII rpatternct|dksd|vr0tjdt|ddt|dkr4t|dz}t d|t|dkr7t|d}t d|g}t|D]}t||}t|tr\t|tjrB|tjtjfvr(|||t|dd} ||}| _ | |||S#t&$rD} t)|j| |j\} } |j| | cYd} ~ Sd} ~ wwxYw|S) z>Return a suite of all test cases contained in the given moduleruse_load_testsz(use_load_tests is deprecated and ignoredNrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}' load_tests)lenwarningswarnDeprecationWarningpoprMformatsorteddirgetattr isinstancer7rKrr8rNappendrUr( Exceptionr,rrF) rmodulerWargskws complainttestsrobjrZe error_case error_messages rloadTestsFromModulezTestLoader.loadTestsFromModulefs t99q==,33 MD, . . . GG$d + + + t99q==D A Iahhirsstt t s88q== s AI[bbclmmnn nKK > >D&$''C3%% >sDM22 > t/DEEE T77<<===V\488 &&  ! "!z$w777 " " ",COQ-9-9) M ""=111!!!!!!!  "  s F$$ G2.9G-'G2-G2c v|d}d\}}||dd}|r d|}t|}n^#t$rO|}t ||j\}}|s|j||cYSYnwxYw||dd}|} |D]} | t| | } } #t$r} t| dd%|#|j||cYd} ~ cSt| | |jdtj \}}|j||cYd} ~ cSd} ~ wwxYwt| tjr|| St| t$rIt'| t(jr/| t(jt(jfvr|| St| tjrt| t$rlt'| t(jrR|d}| |} tt| |tjs|| gSnt| t2jr| St7| rl| }t|t2jr|St|t(jr||gSt9d| d |d t9d | z) aSReturn a suite of all test cases given a string specifier. The name may resolve either to a module, a test case class, a test method within a test case class, or a callable object which returns a TestCase or TestSuite instance. The method optionally resolves the names relative to a given module. .NNNr__path__zFailed to access attribute: zcalling z returned z , not a testz$don't know how to make test from: %s)splitjoin __import__r'r_r*r(rFrercAttributeErrorr&r$r%rdtypes ModuleTyperpr7rKrr8rNrU FunctionTyperrLcallablerM)rrrgpartsrnro parts_copy module_namenext_attributerlpartparentrminstr/s rloadTestsFromNamezTestLoader.loadTestsFromNames 3$.! M >qqqJ * *"%((:"6"6K' 44F"***%/^^%5%5N0H&1919-J %* **=999))))** *  *!""IE & &D &!73#5#5! & & &CT22>". K&&}555%%%%%%%%%1Ba%022251616-J K&&}555%%%%%%%%%% &( c5+ , , ++C00 0 sD ! ! 3 .. DM4+@AAA--c22 2e011 && // 9D6$<C E'.E" E'A E"E'"E'cNfd|D}|S)zReturn a suite of all test cases found using the given sequence of string specifiers. See 'loadTestsFromName()'. c<g|]}|Sr2)r).0rrgrs r z1TestLoader.loadTestsFromNames..s)III4$((v66IIIr)r()rnamesrgsuitess` ` rloadTestsFromNameszTestLoader.loadTestsFromNamess5JIIII5IIIv&&&rcfd}tt|t}jr-|t jj|S)zLReturn a sorted sequence of method names found within testCaseClass c|jsdSt|}t|sdSdjj|fzjduptfdjDS)NFz%s.%s.%sc38K|]}t|VdSr )r)rrWfullNames r zKTestLoader.getTestCaseNames..shouldIncludeMethod..s-XXwK'22XXXXXXr) startswithtestMethodPrefixrcr}rrtestNamePatternsany)attrnametestFuncrrrRs @rshouldIncludeMethodz8TestLoader.getTestCaseNames..shouldIncludeMethods&&t'<== u}h77HH%% u"(-*Dh&H(D0YXXXX$BWXXXXX Yr)key)listfilterrbsortTestMethodsUsingsort functools cmp_to_key)rrRr testFnNamess`` rrOzTestLoader.getTestCaseNamess Y Y Y Y Y Y6"5s=7I7IJJKK  $ R   !5d6O!P!P  Q Q Qrtest*.pycd}||j|j}n|d}|}tj|}|tjvr tjd|||_d}tjtj|retj|}||kr>tjtj|d }n t|tj |}| dd} tjtj |j }nD#t$r7|jtjvrt#ddt#d|dwxYw|r9|||_tj|n#t($rd}YnwxYw|rt)d |zt+|||}||S) a%Find and return all test modules from the specified start directory, recursing into subdirectories to find them and return all tests found within them. Only test files that match the pattern will be loaded. (Using shell style pattern matching.) All test modules must be importable from the top level of the project. If the start directory is not the top level directory then the top level directory must be specified separately. If a test package name (directory with '__init__.py') matches the pattern then the package will be checked for a 'load_tests' function. If this exists then it will be called with (loader, tests, pattern) unless the package has already had load_tests called from the same discovery invocation, in which case the package module object is not scanned for tests - this ensures that when a package uses discover to further discover child tests that infinite recursion does not happen. If load_tests exists then discovery does *not* recurse into the package, load_tests is responsible for loading all tests in the package. The pattern is deliberately not stored as a loader attribute so that packages can continue discovery themselves. top_level_dir is stored so load_tests does not need to pass this argument in to loader.discover(). Paths are sorted before being imported to ensure reproducible execution order even on filesystems with non-alphabetical ordering like ext3/4. FNTr __init__.pyrrz2Can not use builtin modules as dotted module namesz don't know how to discover from z%Start directory is not importable: %r)_top_level_dirr?r@abspathsysinsertisdirisfilerwrxmodulesrvdirname__file__ryrbuiltin_module_namesrM _get_directory_containing_moduleremover'r _find_testsr() r start_dirrW top_level_dirset_implicit_topis_not_importable the_moduletop_partrks rdiscoverzTestLoader.discoverse8!  T%8%D /MM  "# %M 66 (( HOOA} - - -+! 7==33 4 4 3 22IM))(*rw||I}7]7](^(^$^! 39%%%![3 $??3//2 ( ")<>>!@!@II%(((!*c.FFF')ABBGKL(MzMM#'( ($3*.*O*OPX*Y*YD'HOOM222) ) ) )$(!!! ),  SE QRR RT%%i99::u%%%s HAFAG H H ctj|}tj|j}tj|dr> > 7??9-- -rc||jkrdSttj|}tj||j}tj|r Jd|dr Jd|tjj d}|S)NrrzPath must be within the projectz..) rrBr?r@normpathrelpathisabsrreplacesep)rr@_relpathrs r_get_name_from_pathzTestLoader._get_name_from_path]s 4& & &3%bg&6&6t&<&<==7??4)<==7==**MM,MMM*&&t,,OO.OOO, S11 rcDt|tj|Sr )rxrr)rrs r_get_module_from_namez TestLoader._get_module_from_nameis4{4  rc"t||Sr )r)rr@rrWs r _match_pathzTestLoader._match_pathmstW%%%rc#rK||}|dkr,||jvr#|||\}}||V|sdStt j|}|D]}tj||}|||\}}||V|r||}|j| | ||Ed{V|j |#|j |wxYwdS)z/Used by discovery. Yields test suites it loads.rrN) rrH_find_test_pathrar?listdirr@rwaddrdiscard) rrrWrrkshould_recursepathsr@rs rrzTestLoader._find_testsqsv'' 22 3;;4t'===%)$8$8G$L$L !E>  ! rz),,-- 9 9D Y55I$($8$8G$L$L !E>   9// ::&**40009#// 7CCCCCCCCC*2248888D*2248888 9 9 9s DD3ctj|}tj|rt|sdS||||sdS||} ||}tj t|d|}ttj |}ttj |}| | krtj|} ttj|} tj|} d} t| | | | fz|||dfS#t"j$r"} t'|| |jdfcYd} ~ Sd} ~ wt+||j\}}|j||dfcYSxYwtj|rztjtj|dsdSd}d}||} ||}t|dd}|j| |||}||df|j|S|d f|j|S#|j|wxYw#t"j$r"} t'|| |jdfcYd} ~ Sd} ~ wt+||j\}}|j||dfcYSxYwdS) zUsed by discovery. Loads tests from a single file, or a directories' __init__.py when passed the directory. Returns a tuple (None_or_tests_from_file, should_recurse). )NFrzW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?rVFNrrZT)r?r@rrVALID_MODULE_NAMEmatchrrrrrcrBrealpathr=rr'rprSkipTestr;r(r*rFrerrwrHrr)rrrWrrrgmod_filerfullpath_noext module_dirmod_name expected_dirmsgrmrnrorZrkpackages rrzTestLoader._find_test_paths7##I.. 7>>) $ $? $**844 #"{##HiAA #"{++I66D P33D997??FJ ::<<1G$$X..00!7G$$Y//"1"1>>##~';';'='===!#!:!:J5((33 5 5H#%7??9#=#=LDC%x\BBDDD///HH%OO/= K K K)$4?CCUJJJJJJJ ),T4?CC* M ""=111!5(((($W]]9 % % 7>>"',,y-"H"HII #"{JE++I66D 944T::%WlDAA &**40009 44Wg4NNE!-$e|*2248888!$;*2248888D*2248888%= K K K)$4?CCUJJJJJJJ ),T4?CC* M ""=111!5((((;sN G**I9HI;INM%M%%NO-N0*O-0;O-r )rN)rrr__doc__r staticmethodr three_way_cmprrrrLr(rrrUrprrrOrrrrrrrr r!s@rrDrDBsX'<(:;;JN'''''$:>*****XPJPJPJPJd''''&Q&Q&Q&Q&f . . .   !!!&&&999@HHHHHHHrrDc^t}||_||_||_|r||_|Sr )rDrrrr()prefix sortUsingr(rloaders r _makeLoaderrs8 \\F"+F$F.F'& Mrcddl}|jdtdt||||S)Nrzunittest.getTestCaseNames() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.getTestCaseNames() instead. stacklevel)r)r\r]r^rrO)rRrrrr\s rrOrOsXOOOHM Eq vy;K L L L ] ]^k l llrr/cddl}|jdtdt||||S)Nrzunittest.makeSuite() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromTestCase() instead.rr)r\r]r^rrU)rRrrr(r\s r makeSuitersZOOOHM Jq vy* 5 5 K K  rcddl}|jdtdt||||S)Nrzunittest.findTestCases() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromModule() instead.rr)r\r]r^rrp)rgrrr(r\s r findTestCasesrsZOOOHM Hq vy* 5 5 I I  rrs)"rr?rerr$rzrr\rrrrr __unittestcompile IGNORECASErr8r r*r,r&r;rBobjectrDdefaultTestLoaderrrrOrLrrr2rrrs  ((((((((  BJ0"-@@     $-   NNN ... (((000%%% WWWWWWWWt JLL 7;6H[_mmmm%+d6H    "(43E"_      r