o ?Og4@s|dZddlZddlmZddlmZdZddZGd d d eZGd ddeZ Gd d d eZ ddZ GdddeZ dS) TestSuiteN)case)utilTcCst||dd}|dS)NcSdSNrrr5/opt/alt/python310/lib64/python3.10/unittest/suite.py sz!_call_if_exists..)getattr)parentattrfuncrrr _call_if_exists s rc@sneZdZdZdZdddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZdS) BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures. TrcCsg|_d|_||dSNr)_tests_removed_testsaddTests)selftestsrrr __init__szBaseTestSuite.__init__cCsdt|jt|fS)Nz <%s tests=%s>)rstrclass __class__listrrrr __repr__szBaseTestSuite.__repr__cCs t||jstSt|t|kSr) isinstancerNotImplementedr)rotherrrr __eq__s zBaseTestSuite.__eq__cCs t|jSr)iterrrrrr __iter__" zBaseTestSuite.__iter__cCs$|j}|D] }|r||7}q|Sr)rcountTestCases)rcasestestrrr r$%s  zBaseTestSuite.countTestCasescCsLt|s tdt|t|trt|tjt frtd|j |dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest()) callable TypeErrorformatreprrtype issubclassrZTestCaserrappendrr&rrr addTest,szBaseTestSuite.addTestcCs*t|tr td|D]}||q dS)Nz0tests must be an iterable of tests, not a string)rstrr(r/)rrr&rrr r6s  zBaseTestSuite.addTestscCs:t|D]\}}|jr|S|||jr||q|Sr) enumerate shouldStop_cleanup_removeTestAtIndex)rresultindexr&rrr run<s zBaseTestSuite.runcCsNz|j|}Wn tyYdSwt|dr |j|7_d|j|<dS)z2Stop holding a reference to the TestCase at index.r$N)rr(hasattrrr$)rr6r&rrr r4Es  z BaseTestSuite._removeTestAtIndexcOs|j|i|Srr7)rargskwdsrrr __call__SszBaseTestSuite.__call__cCs|D]}|qdS)7Run the tests without collecting errors in a TestResultN)debugr.rrr r>Vs zBaseTestSuite.debugN)r)__name__ __module__ __qualname____doc__r3rrr r"r$r/rr7r4r<r>rrrr rs    rc@sbeZdZdZdddZddZddZd d Zd d Z dddZ dddZ ddZ ddZ d S)raA test suite is a composite test consisting of a number of TestCases. For use, create an instance of TestSuite, then add test case instances. When all tests have been added, the suite can be passed to a test runner, such as TextTestRunner. It will run the individual test cases in the order in which they were added, aggregating the results. When subclassing, do not forget to call the base class constructor. FcCsd}t|dddurd|_}t|D]D\}}|jrnr3r4_handleModuleTearDown)rr5r>ZtopLevelr6r&rrr r7fs4         z TestSuite.runcCst}||ddS)r=TN) _DebugResultr7)rr>rrr r>szTestSuite.debugc Cstt|dd}|j}||krdS|jrdSt|ddrdSd}zd|_Wn ty,Ynwt|dd}t|dd}|durt|dzoz|Wn6ty~}z*t|trVd}zd|_Wn tyfYnwt |} | ||d| WYd}~nd}~ww|r|dur||j D]} |j || dd| | d qWt|d dSWt|d dSWt|d dSt|d wdS) NrJ__unittest_skip__F setUpClassdoClassCleanups _setupStdoutTrinfo_restoreStdout) r rrErDr(r ExceptionrrLrr"_createClassOrModuleLevelExceptiontearDown_exceptions) rr&r5 previousClass currentClassZfailedrNrOe classNameexc_inforrr rIsf               zTestSuite._handleClassSetUpcCs"d}t|dd}|dur|j}|S)NrJ)r r@)rr5previousModulerWrrr _get_previous_modules  zTestSuite._get_previous_modulec CsL||}|jj}||krdS||d|_ztj|}Wn ty(YdSwt|dd}|durt |dzez|Wn#t ya}zt |t rLd|_| ||d|WYd}~nd}~ww|jrztWn"t y}z| ||d|WYd}~nd}~wwWt |ddSWt |ddSWt |ddSt |dwdS)NF setUpModulerPTrS)r]rr@rKrEsysmodulesKeyErrorr rrTrrLrUrdoModuleCleanups)rr&r5r\Z currentModulemoduler^rYrrr rHsX        zTestSuite._handleModuleFixtureNcCs$|d|d}|||||dS)Nz ())_addClassOrModuleLevelException)rr5excZ method_namer rR errorNamerrr rUsz,TestSuite._createClassOrModuleLevelExceptioncCsbt|}t|dd}|durt|tjr||t|dS|s)||tdS|||dS)NaddSkip) _ErrorHolderr rrZSkipTestr0ZaddErrorr_r[)rr5Z exceptionrgrRerrorrhrrr res z)TestSuite._addClassOrModuleLevelExceptionc Cs*||}|dur dS|jrdSztj|}Wn ty!YdSwt|dzgt|dd}|durXz|Wn tyW}zt|t rE| ||d|WYd}~nd}~wwzt Wn ty~}zt|t rl| ||d|WYd}~n d}~wwWt|ddSWt|ddSt|dw)NrPtearDownModulerS) r]rEr_r`rarr rTrrLrUrrb)rr5r\rcrkrYrrr rKsP        zTestSuite._handleModuleTearDownc Csft|dd}|j}||ks|durdSt|ddrdSt|ddr#dSt|ddr+dSt|dd}t|dd}|durA|durAdSt|dzf|durvz|Wn%tyu}zt|tr^t|}|||d|WYd}~nd}~ww|dur||j D]$} t|tr| d t|}|j|| d d|| d qWt|d dSWt|d dSt|d w) NrJrDFrErM tearDownClassrOrPrrQrS) r rrrTrrLrrrUrV) rr&r5rWrXrlrOrYrZr[rrr rGsX                z TestSuite._tearDownPreviousClass)Fr) r?r@rArBr7r>rIr]rHrUrerKrGrrrr r\s !.&   #c@sTeZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ dS)riz Placeholder for a TestCase inside a result. As far as a TestResult is concerned, this looks exactly like a unit test. Used to insert arbitrary errors into a test suite run. NcCs ||_dSr description)rrnrrr rTr#z_ErrorHolder.__init__cCs|jSrrmrrrr idWsz_ErrorHolder.idcCrrrrrrr shortDescriptionZz_ErrorHolder.shortDescriptioncCs d|jfS)Nzrmrrrr r]s z_ErrorHolder.__repr__cCs|Sr)rorrrr __str__`sz_ErrorHolder.__str__cCrrrrr5rrr r7csz_ErrorHolder.runcCs ||Srr9rsrrr r<hr#z_ErrorHolder.__call__cCsdSrrrrrr r$krqz_ErrorHolder.countTestCases) r?r@rArBZfailureExceptionrrorprrrr7r<r$rrrr riHs  ricCs$zt|WdStyYdSw)z?A crude way to tell apart testcases and suites with duck-typingTF)r!r()r&rrr rFns   rFc@seZdZdZdZdZdZdS)rLzCUsed by the TestSuite to hold previous class when running in debug.NF)r?r@rArBrJrEr2rrrr rLws rL) rBr_rrZ __unittestrobjectrrrirFrLrrrr s  Lm&