g|RdZddlZddlZddlZddlZddlZddlZddlmZmZddl m Z m Z m Z dZ ejdejZGdd e j"Zd Zd Zd Zd ZdZGddeZeZddZe j8dfdZde j8e j<fdZde j8e j<fdZ y)zLoading unittests.N)fnmatch fnmatchcase)casesuiteutilTz[_a-z]\w*\.py$c,eZdZdZfdZfdZxZS) _FailedTestNc:||_tt||yN) _exceptionsuperr __init__)self method_name exception __class__s 6/opt/alt/python312/lib64/python3.12/unittest/loader.pyrz_FailedTest.__init__s# k4)+6cX|jk7rtt|Sfd}|S)Ncjr )r rsr testFailurez,_FailedTest.__getattr__..testFailure s // !r)_testMethodNamerr __getattr__)rnamerrs` rrz_FailedTest.__getattr__s. 4'' 'd7= = "r)__name__ __module__ __qualname__rrr __classcell__rs@rr r sO7rr cdd|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#7W MMrcLdtj}t||||S)NzFailed to call load_tests: )r$r%r&)rrr(r)s r_make_failed_load_testsr,*s)2;2F2F2HJG  iW ..rc0t||}||f|fSr )r ) methodnamerr(r)tests rr&r&/s z9 -D tg  ''rctjt|d}||i}tdtjf|}|||fS)Ncyr rs r testSkippedz'_make_skipped_test..testSkipped4s r ModuleSkipped)rskipstrtypeTestCase)r.rr(r3attrs TestClasss r_make_skipped_testr;3sS YYs9~   %E_t}}&6>I y,. //rcFtjj|dS)Nr)ospathsplitext)r>s r _splitextr@;s 77  D !! $$rceZdZdZdZeejZdZ e jZ dZ fdZdZdddZddZdd Zd Zdd Zd Zd ZdZdZdZdZxZS) TestLoaderz This class is responsible for loading tests according to various criteria and returning them wrapped in a TestSuite r/NcVtt| g|_t |_yr )rrBrerrorsset_loading_packages)rrs rrzTestLoader.__init__Js# j$(* "%rct|tjr td|tj tj fvrg}n"|j|}|st|drdg}|jt||}|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.loadTestsFromTestCaseQs~ mU__ 5() ) T]]D,A,AB BM 11-@M W]I%F!* s=-'HI rpatternc$g}t|D]}}t||}t|ts t |t j s;|t j t jfvs^|j|j|t|dd}|j|}| ||||S|S#t$rK}t|j||j\}} |jj| |cYd}~Sd}~wwxYw)z>Return a suite of all test cases contained in the given module load_testsN)dirgetattr isinstancer7rIrr8rLappendrSr( Exceptionr,rrD) rmodulerUtestsrobjrWe error_case error_messages rloadTestsFromModulezTestLoader.loadTestsFromModuleasKD&$'C3%sDMM2 t/D/DEE T77<= V\48 &  ! "!$w77   ",COOQ-9) M ""=1!!  "s/ B;; DAD D Dc |jd}d\}}|*|dd}|r dj|}t|} |dd}|} |D]} | t| | } } t| tj r|j#| St| t$rMt'| t(j*r3| t(j*t(j,fvr|j/| St| tj0rmt t$r]t'| t(j*rC|d}| |} tt| |tj0s.|j | gSt| t2j4r| St7| ra| }t|t2j4r|St|t(j*r|j |gSt9d| d |d t9d | z#t$rM|j }t ||j \}}|s|jj||cYSYnwxYw|r=!#t$r} t| dd&|$|jj||cYd} ~ cSt| | |j dtj\}}|jj||cYd} ~ cSd} ~ wwxYw) 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'popr*r(rDr[rYAttributeErrorr&r$r%rZtypes ModuleTypercr7rIrr8rLrS FunctionTyperrJcallablerK)rrr]partsrarb parts_copy module_namenext_attributer_partparentr`instr/s rloadTestsFromNamezTestLoader.loadTestsFromNameys 3$.! M >qJ *"%((:"6K' 4F!"IED &!73#5. c5++ ,++C0 0 sD !3 .DMM4+@+@AA--c2 2e001&/9D$". KK&&}5%%1Ba%002516-J KK&&}5%%% &s=H IAII K4(+K/K4A K/'K4/K4cl|Dcgc]}|j||}}|j|Scc}w)zReturn a suite of all test cases found using the given sequence of string specifiers. See 'loadTestsFromName()'. )ryr()rnamesr]rsuitess rloadTestsFromNameszTestLoader.loadTestsFromNamess<DII54$((v65Iv&&Js1cfd}tt|t}jr/|j t j j|S)zLReturn a sorted sequence of method names found within testCaseClass c|jjsyt|}t|sydjj |fzj duxstfdj DS)NFz%s.%s.%sc36K|]}t|ywr )r).0rUfullNames r zKTestLoader.getTestCaseNames..shouldIncludeMethod..sXBWwK'2BWs) startswithtestMethodPrefixrYrqrrtestNamePatternsany)attrnametestFuncrrrPs @rshouldIncludeMethodz8TestLoader.getTestCaseNames..shouldIncludeMethods&&t'<'<=}h7HH%!((-*D*Dh&H((D0YX$BWBWXX Yr)key)listfilterrXsortTestMethodsUsingsort functools cmp_to_key)rrPr testFnNamess`` rrMzTestLoader.getTestCaseNamessS Y6"5s=7IJK  $ $   !5!5d6O6O!P  Qrc|j}d}||j |j}n|d}|}tjj|}|tjvr tjj d|||_d}tjj tjj|rctjj|}||k7rtjjtjj|d }n t|tj|}|jdd} tjjtjj|j}|r6|j%||_tjj'| |rt)d |zt+|j-||} ||_|j/| S#t$r8|jtj vr t#ddt#d|dwxYw#t($rd}YwxYw) 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__.pyrez2Can 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>abspathsysinsertisdirisfilerjrkmodulesridirname__file__rmrbuiltin_module_namesrK _get_directory_containing_moduleremover'r _find_testsr() r start_dirrU top_level_diroriginal_top_level_dirset_implicit_topis_not_importable the_moduletop_partr^s rdiscoverzTestLoader.discovers8"&!4!4   T%8%8%D //M  "# %M 6 ( HHOOA} -+! 77==3 4 2IM)(*rww||I}7](^$^! 39%![[3 $??3/2 ( ")<)<>!@I$*.*O*OPX*YD'HHOOM2 E QR RT%%i9:4u%%'&(!**c.F.FF')ABGKL(>znM#'( ( )$(! )s * I"AHAI" I0/I0ctj|}tjj |j }tjj |jjdrrrbasenamelowerrr)rrtr] full_paths rrz+TestLoader._get_directory_containing_module:s[)GGOOFOO4 77  I & , , . 9 9- H77??277??9#=> > 77??9- -rc||jk(ryttjj |}tjj ||j}tjj |rJd|jdrJd|jtjjd}|S)NrezPath must be within the projectz..) rr@r=r>normpathrelpathisabsrreplacesep)rr>_relpathrs r_get_name_from_pathzTestLoader._get_name_from_pathFs 4&& &))$/077??4)<)<=77==*M,MM*&&t,O.OO, S1 rc>t|tj|Sr )rkrr)rrs r_get_module_from_namez TestLoader._get_module_from_nameRs4{{4  rct||Sr )r)rr>rrUs r _match_pathzTestLoader._match_pathVstW%%rc#^K|j|}|dk7r,||jvr|j||\}}|||sytt j |}|D]}tj j||}|j||\}}|||sA|j|}|jj| |j||Ed{|jj|y7"#|jj|wxYww)z/Used by discovery. Yields test suites it loads.reN) rrF_find_test_pathsortedr=listdirr>rjaddrdiscard) rrrUrr^should_recursepathsr>rs rrzTestLoader._find_testsZs'' 2 3;4t'='==%)$8$8G$L !E>  !rzz),-D Y5I$($8$8G$L !E>  // :&&**409#// 7CCC**2248D**2248s6B#D-&,D-D (D )D -D- D  D**D-cztjj|}tjj|rvtj |sy|j |||sy|j|} |j|}tjjt|d|}ttjj|}ttjj|}|j|jk7rytjj|} ttjj|} tjj|} d} t| | | | fz|j!||dfStjj1|rtjjtjj3|dsyd}d}|j|} |j|}t|dd}|j4j7| |j!||}||df|j4j9|S|d f|j4j9|Sy#t"j$$r#} t'|| |j(dfcYd} ~ Sd} ~ wt+||j(\}}|j,j/||dfcYSxYw#|j4j9|wxYw#t"j$$r#} t'|| |j(dfcYd} ~ Sd} ~ wt+||j(\}}|j,j/||dfcYSxYw) 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?rTFNrrWT)r=r>rrVALID_MODULE_NAMEmatchrrrrrYr@realpathrrr'rcrSkipTestr;r(r*rDr[rrjrFrr)rrrUrrr]mod_filerfullpath_noext module_dirmod_name expected_dirmsgr`rarbrWr^packages rrzTestLoader._find_test_pathzs%77##I. 77>>) $$**84"##HiA"++I6D P33D977??FJ :<$GG$$X.0!*GG$$Y/"1>>#~';';'==!#!:J(((3 5H#%77??9#=LDC%x\BBDD///H%OO WW]]9 %77>>"'',,y-"HI"JE++I6D 944T:%WlDA &&**409 44Wg4NE!-$e|**2248!$;**2248k== K)$4??CUJJ ),T4??C* M ""=1!5((Z**2248%== K)$4??CUJJ ),T4??C* M ""=1!5((sN<J7)M #L*L*7L' K("L'(=L'*M N:M;5N:;=N:r )ztest*.pyN)rrr__doc__r staticmethodr three_way_cmprrrrJr(rrrSrcryr}rMrrrrrrrr r!s@rrBrB?s'(:(:;JN' 6:0PJd'&S&j . !&9@HrrBcVt}||_||_||_|r||_|Sr )rBrrrr()prefix sortUsingr(rloaders r _makeLoaderrs1 \F"+F$F.F& Mrctddl}|jdtdt|||j |S)Nrzunittest.getTestCaseNames() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.getTestCaseNames() instead. stacklevel)r)warningswarnDeprecationWarningrrM)rPrrrrs rrMrMs? MM Eq vy;K L ] ]^k llrr/crddl}|jdtdt|||j |S)Nrzunittest.makeSuite() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromTestCase() instead.rr)rrrrrS)rPrrr(rs r makeSuitersB MM Jq vy* 5 K K rcrddl}|jdtdt|||j |S)Nrzunittest.findTestCases() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromModule() instead.rr)rrrrrc)r]rrr(rs r findTestCasesrsB MM Hq vy* 5 I I rrf)!rr=rerr$rnrrrrrr __unittestcompile IGNORECASErr8r r*r,r&r;r@objectrBdefaultTestLoaderrrrMrJrrr2rrrs  (  BJJ0"--@ $-- N . (0%CCL L 7;6H6H[_m%+d6H6H "(43E3E"__ r