a d4@s|dZddlZddlmZddlmZdZddZGd d d eZGd ddeZ Gd d d eZ ddZ GdddeZ dS) TestSuiteN)case)utilTcCst||dd}|dS)NcSsdSNrrr&/usr/lib64/python3.9/unittest/suite.py z!_call_if_exists..)getattr)parentattrfuncrrr_call_if_exists src@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__"szBaseTestSuite.__iter__cCs$|j}|D]}|r ||7}q |Sr)rcountTestCases)rcasestestrrrr#%s zBaseTestSuite.countTestCasescCsLt|stdt|t|tr|j|7_d|j|<dS)z2Stop holding a reference to the TestCase at index.r#N)rr'hasattrrr#)rr6r%rrrr4Es  z BaseTestSuite._removeTestAtIndexcOs|j|i|Srr7)rargskwdsrrr__call__SszBaseTestSuite.__call__cCs|D] }|qdS)7Run the tests without collecting errors in a TestResultN)debugr.rrrr>VszBaseTestSuite.debugN)r)__name__ __module__ __qualname____doc__r3rrr r"r#r/rr7r4r<r>rrrrrs   rc@s^eZdZdZdddZddZddZd d Zd d ZdddZ 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]\}}|jr8qt|r||||||||||j|_ t|jdds&t|ddrq&|s||n| |j r&| |q&|r|d|| |d|_|S)NF_testRunEnteredT_classSetupFailed_moduleSetUpFailed)r rCr1r2 _isnotsuite_tearDownPreviousClass_handleModuleFixture_handleClassSetUpr_previousTestClassr>r3r4_handleModuleTearDown)rr5r>topLevelr6r%rrrr7fs2         z TestSuite.runcCst}||ddS)r=TN) _DebugResultr7)rr>rrrr>szTestSuite.debugc CsZt|dd}|j}||krdS|jr(dSt|ddr8dSd}z d|_WntyXYn0t|dd}t|dd}|durVt|dzz |Wnlty}zTt|trd}z d|_WntyYn0t |} | ||d| WYd}~n d}~00|r<|dur<||j D]} |j || dd| | d qWt|d n t|d 0dS) NrJ__unittest_skip__F setUpClassdoClassCleanups _setupStdoutTrinfo_restoreStdout) r rrErDr'r ExceptionrrMrr"_createClassOrModuleLevelExceptiontearDown_exceptions) rr%r5 previousClass currentClassfailedrOrPe classNameexc_inforrrrIsR                zTestSuite._handleClassSetUpcCs"d}t|dd}|dur|j}|S)NrJ)r r@)rr5previousModulerXrrr_get_previous_modules  zTestSuite._get_previous_modulec Cs0||}|jj}||krdS||d|_ztj|}WntyPYdS0t|dd}|dur,t |dzz |WnFt y}z.t |t rd|_| ||d|WYd}~n d}~00|jrz tWn6t y}z| ||d|WYd}~n d}~00Wt |dn t |d0dS)NF setUpModulerQTrT)r_rr@rKrEsysmodulesKeyErrorr rrUrrMrVrdoModuleCleanups)rr%r5r^ currentModulemoduler`r[rrrrHsB         zTestSuite._handleModuleFixtureNcCs$|d|d}|||||dS)Nz ())_addClassOrModuleLevelException)rr5exc method_namer rS errorNamerrrrVsz,TestSuite._createClassOrModuleLevelExceptioncCs^t|}t|dd}|dur8t|tjr8||t|n"|sN||tn |||dS)NaddSkip) _ErrorHolderr rrSkipTestr0addErrorrar])rr5 exceptionrkrSerrorrlrrrrhs z)TestSuite._addClassOrModuleLevelExceptionc Cs||}|durdS|jr dSztj|}WntyBYdS0t|dzt|dd}|durz |Wn@ty}z(t|t r| ||d|WYd}~n d}~00z t WnBty}z(t|t rڂ| ||d|WYd}~n d}~00Wt|dn t|d0dS)NrQtearDownModulerT) r_rErarbrcrr rUrrMrVrrd)rr5r^rfrrr[rrrrKs@        zTestSuite._handleModuleTearDownc Cs^t|dd}|j}||ks"|dur&dSt|ddr6dSt|ddrFdSt|ddrVdSt|dd}t|dd}|dur|durdSt|dz|durz |WnJty}z2t|trt|}|||d|WYd}~n d}~00|dur@||j D]<} t|tr| d t|}|j|| d d|| d qWt|d n t|d 0dS) NrJrDFrErN tearDownClassrPrQrrRrT) r rrrUrrMrrrVrW) rr%r5rXrYrsrPr[r\r]rrrrGsN                z TestSuite._tearDownPreviousClass)F)N)N) r?r@rArBr7r>rIr_rHrVrhrKrGrrrrr\s !.&  #c@sTeZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ dS)rmz 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)rrurrrrTsz_ErrorHolder.__init__cCs|jSrrtrrrridWsz_ErrorHolder.idcCsdSrrrrrrshortDescriptionZsz_ErrorHolder.shortDescriptioncCs d|jfS)Nzrtrrrrr]sz_ErrorHolder.__repr__cCs|Sr)rvrrrr__str__`sz_ErrorHolder.__str__cCsdSrrrr5rrrr7csz_ErrorHolder.runcCs ||Srr9ryrrrr<hsz_ErrorHolder.__call__cCsdSrrrrrrr#ksz_ErrorHolder.countTestCases) r?r@rArBfailureExceptionrrvrwrrxr7r<r#rrrrrmHs rmcCs&z t|Wnty YdS0dS)z?A crude way to tell apart testcases and suites with duck-typingTF)r!r')r%rrrrFns   rFc@seZdZdZdZdZdZdS)rMzCUsed by the TestSuite to hold previous class when running in debug.NF)r?r@rArBrJrEr2rrrrrMwsrM) rBrarr __unittestrobjectrrrmrFrMrrrrs  Lm&