o 0¦iÈ4ã@s|dZddlZddlmZddlmZdZdd„ZGd d „d eƒZGd d„deƒZ Gd d „d eƒZ dd„Z Gdd„deƒZ dS)Ú TestSuiteéNé)Úcase)ÚutilTcCst||dd„ƒ}|ƒdS)NcSódS©N©rrrú5/opt/alt/python310/lib64/python3.10/unittest/suite.pyÚ sz!_call_if_exists..)Úgetattr)ÚparentÚattrÚfuncrrr Ú_call_if_exists s rc@sneZdZdZdZddd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„ZdS)Ú BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures. TrcCsg|_d|_| |¡dS©Nr)Ú_testsÚ_removed_testsÚaddTests)ÚselfÚtestsrrr Ú__init__szBaseTestSuite.__init__cCsdt |j¡t|ƒfS)Nz <%s tests=%s>)rÚstrclassÚ __class__Úlist©rrrr Ú__repr__szBaseTestSuite.__repr__cCs t||jƒstSt|ƒt|ƒkSr)Ú isinstancerÚNotImplementedr)rÚotherrrr Ú__eq__s zBaseTestSuite.__eq__cCs t|jƒSr)Úiterrrrrr Ú__iter__"ó zBaseTestSuite.__iter__cCs$|j}|D] }|r|| ¡7}q|Sr)rÚcountTestCases)rÚcasesÚtestrrr r$%s  €zBaseTestSuite.countTestCasescCsLt|ƒs td t|ƒ¡ƒ‚t|tƒrt|tjt fƒrtdƒ‚|j   |¡dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest()) ÚcallableÚ TypeErrorÚformatÚreprrÚtypeÚ issubclassrZTestCaserrÚappend©rr&rrr ÚaddTest,sÿzBaseTestSuite.addTestcCs*t|tƒr tdƒ‚|D]}| |¡q dS)Nz0tests must be an iterable of tests, not a string)rÚstrr(r/)rrr&rrr r6s  ÿzBaseTestSuite.addTestscCs:t|ƒD]\}}|jr|S||ƒ|jr| |¡q|Sr)Ú enumerateÚ shouldStopÚ_cleanupÚ_removeTestAtIndex)rÚresultÚindexr&rrr Úrun<sý €zBaseTestSuite.runcCsNz|j|}Wn tyYdSwt|dƒr |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|¤ŽSr©r7)rÚargsÚkwdsrrr Ú__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@sbeZdZdZddd„Zdd„Zdd„Zd d „Zd d „Z ddd„Z ddd„Z dd„Z dd„Z d S)ra³A 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. FcCsÔd}t|ddƒdurd|_}t|ƒD]D\}}|jrnr3r4Ú_handleModuleTearDown)rr5r>ZtopLevelr6r&rrr r7fs4     ÿ  €  z TestSuite.runcCstƒ}| |d¡dS)r=TN)Ú _DebugResultr7)rr>rrr r>‡szTestSuite.debugc Cstt|ddƒ}|j}||krdS|jrdSt|ddƒrdSd}zd|_Wn ty,Ynwt|ddƒ}t|ddƒ}|dur¸t|dƒzoz|ƒWn6ty~}z*t|tƒrV‚d}zd|_Wn tyfYnwt   |¡} |  ||d| ¡WYd}~nd}~ww|rš|dur¢|ƒ|j D]} |j || dd| | d �q‹Wt|d ƒdSWt|d ƒdSWt|d ƒdSt|d ƒwdS) NrJÚ__unittest_skip__FÚ setUpClassÚdoClassCleanupsÚ _setupStdoutTr©ÚinfoÚ_restoreStdout) r rrErDr(rÚ ExceptionrrLrrÚ"_createClassOrModuleLevelExceptionÚtearDown_exceptions) rr&r5Ú previousClassÚ currentClassZfailedrNrOÚeÚ classNameÚexc_inforrr rIŽsf    ý       ÿ þ€÷   þýùûèzTestSuite._handleClassSetUpcCs"d}t|ddƒ}|dur|j}|S)NrJ)r r@)rr5ÚpreviousModulerWrrr Ú_get_previous_module¼s  zTestSuite._get_previous_modulec CsL| |¡}|jj}||krdS| |¡d|_ztj|}Wn ty(YdSwt|ddƒ}|dur¤t |dƒzez|ƒWn#t ya}zt |t ƒrL‚d|_|  ||d|¡WYd}~nd}~ww|jr†zt ¡Wn"t y…}z|  ||d|¡WYd}~nd}~wwWt |dƒdSWt |dƒdSWt |dƒdSt |dƒwdS)NFÚ setUpModulerPTrS)r]rr@rKrEÚsysÚmodulesÚKeyErrorr rrTrrLrUrÚdoModuleCleanups)rr&r5r\Z currentModuleÚmoduler^rYrrr rHÄsX   ÿ    þ€ü þ€ÿýúüìzTestSuite._handleModuleFixtureNcCs$|›d|›d�}| ||||¡dS)Nz (ú))Ú_addClassOrModuleLevelException)rr5ÚexcZ method_namer rRÚ errorNamerrr rUész,TestSuite._createClassOrModuleLevelExceptioncCsbt|ƒ}t|ddƒ}|durt|tjƒr||t|ƒƒdS|s)| |t ¡¡dS| ||¡dS)NÚaddSkip) Ú _ErrorHolderr rrZSkipTestr0ZaddErrorr_r[)rr5Z exceptionrgrRÚerrorrhrrr reîs z)TestSuite._addClassOrModuleLevelExceptionc Cs*| |¡}|dur dS|jrdSztj|}Wn ty!YdSwt|dƒzgt|ddƒ}|durXz|ƒWn tyW}zt|t ƒrE‚|  ||d|¡WYd}~nd}~wwzt   ¡Wn ty~}zt|t ƒrl‚|  ||d|¡WYd}~n d}~wwWt|dƒdSWt|dƒdSt|dƒw)NrPÚtearDownModulerS) r]rEr_r`rarr rTrrLrUrrb)rr5r\rcrkrYrrr rKúsP  ÿ    þ€ý  þ€ýÿüzTestSuite._handleModuleTearDownc Csft|ddƒ}|j}||ks|durdSt|ddƒrdSt|ddƒr#dSt|ddƒr+dSt|ddƒ}t|ddƒ}|durA|durAdSt|dƒzf|durvz|ƒWn%tyu}zt|tƒr^‚t |¡}| ||d|¡WYd}~nd}~ww|dur�|ƒ|j D]$} t|tƒr‹| d ‚t |¡}|j|| d d|| d �q€Wt|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@sTeZdZdZdZdd„Zdd„Zdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z 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 ÚshortDescriptionZóz_ErrorHolder.shortDescriptioncCs d|jfS)Nzrmrrrr r]s z_ErrorHolder.__repr__cCs| ¡Sr)rorrrr Ú__str__`sz_ErrorHolder.__str__cCrrr©rr5rrr 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 __unittestrÚobjectrrrirFrLrrrr Ús  Lm&