a DOgC@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZmZmZmZmZdZeZdZGdd d eZGd d d eZGd d d eZGdddeZddZgZddZddZddZ ddZ!ddZ"ddZ#ddZ$Gd d!d!Z%Gd"d#d#e%Z&Gd$d%d%e&Z'Gd&d'd'e&Z(Gd(d)d)ej)Z*Gd*d+d+eZ+Gd,d-d-e+Z,Gd.d/d/e+Z-dS)0zTest case implementationN)result)strclass safe_repr_count_diff_all_purpose_count_diff_hashable_common_shorten_reprTz@ Diff is %s characters long. Set self.maxDiff to None to see it.c@seZdZdZdS)SkipTestz Raise this exception in a test to skip it. Usually you can use TestCase.skipTest() or one of the skipping decorators instead of raising this directly. N__name__ __module__ __qualname____doc__rr2/opt/alt/python39/lib64/python3.9/unittest/case.pyr sr c@seZdZdZdS) _ShouldStopz The test should stop. Nr rrrrr!src@seZdZdZdS)_UnexpectedSuccessz7 The test was supposed to fail, but it didn't! Nr rrrrr&src@s&eZdZdddZejdddZdS) _OutcomeNcCs4d|_||_t|d|_d|_g|_d|_g|_dS)NF addSubTestT)expecting_failurerhasattrresult_supports_subtestssuccessskippedexpectedFailureerrors)selfrrrr__init__-s z_Outcome.__init__Fc cs|j}d|_zz dVWnty,Yntyh}z&d|_|j|t|fWYd}~npd}~0tyxYnXt}|j r||_ nd|_|j ||fd}Yn0|j r|jr|j |dfW|jo||_n|jo||_0dS)NTF) rKeyboardInterruptr rappendstrrsysexc_inforrrr)r test_caseisTestZ old_successer"rrrtestPartExecutor6s*  (   z_Outcome.testPartExecutor)N)F)r r r r contextlibcontextmanagerr&rrrrr,s rcCs|SNr)objrrr_idTsr+cOst|||fdS)znSame as addCleanup, except the cleanup items are called even if setUpModule fails (unlike tearDownModule).N)_module_cleanupsr)functionargskwargsrrraddModuleCleanupYsr0c Csjg}trZt\}}}z||i|WqtyV}z||WYd}~qd}~00q|rf|ddS)zWExecute all module cleanup functions. Normally called for you after tearDownModule.Nr)r,pop Exceptionr) exceptionsr-r.r/excrrrdoModuleCleanups_s"r5cs,fdd}ttjr(}d||S|S)z& Unconditionally skip a test. cs4t|ts$t|fdd}|}d|_|_|S)Ncs tdSr)r r.r/reasonrr skip_wrapperusz-skip..decorator..skip_wrapperT) isinstancetype functoolswraps__unittest_skip____unittest_skip_why__) test_itemr:r8rr decoratorss zskip..decorator)r;types FunctionType)r9rBrArr8rskipos  rFcCs|r t|StS)z/ Skip a test if the condition is true. rFr+Z conditionr9rrrskipIfsrIcCs|s t|StS)z3 Skip a test unless the condition is true. rGrHrrr skipUnlesssrJcCs d|_|S)NT)__unittest_expecting_failure__)rArrrrsrcs4t|tr tfdd|DSt|to2t|S)Nc3s|]}t|VqdSr)) _is_subtype).0r%basetyperr z_is_subtype..)r;tupleallr< issubclass)expectedrOrrNrrLs rLc@seZdZddZddZdS)_BaseTestCaseContextcCs ||_dSr))r#)rr#rrrrsz_BaseTestCaseContext.__init__cCs |j|j|}|j|dSr))r#_formatMessagemsgfailureException)r standardMsgrXrrr _raiseFailuresz"_BaseTestCaseContext._raiseFailureN)r r r rr[rrrrrVsrVc@seZdZdddZddZdS)_AssertRaisesBaseContextNcCs@t||||_||_|dur*t|}||_d|_d|_dSr)) rVrrUr#recompileexpected_regexobj_namerX)rrUr#r_rrrrs  z!_AssertRaisesBaseContext.__init__cCszt|j|js"td||jf|sX|dd|_|rNtdtt|f|Wd}S|^}}z |j |_ Wnt yt ||_ Yn0|||i|Wdn1s0YWd}nd}0dS)z If args is empty, assertRaises/Warns is being used as a context manager, so check for a 'msg' kwarg and return self. If args is not empty, call a callable passing positional and keyword arguments. z%s() arg 1 must be %srXNz3%r is an invalid keyword argument for this function) rLrU _base_type TypeError_base_type_strr1rXnextiterr r`AttributeErrorr )rnamer.r/Z callable_objrrrhandles,    .z_AssertRaisesBaseContext.handle)N)r r r rrhrrrrr\s r\c@s2eZdZdZeZdZddZddZe e j Z dS)_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typescCs|Sr)rrrrr __enter__sz_AssertRaisesContext.__enter__cCs|dur`z |jj}Wnty0t|j}Yn0|jrN|d||jqj|d|n t|t ||jszdS| d|_ |j durdS|j }| t|s|d|jt|dS)Nz{} not raised by {}z {} not raisedFT"{}" does not match "{}")rUr rfr r`r[format traceback clear_framesrTwith_tracebackZ exceptionr_searchpattern)rexc_type exc_valuetbexc_namer_rrr__exit__s,        z_AssertRaisesContext.__exit__N) r r r r BaseExceptionrarcrkrw classmethodrD GenericAlias__class_getitem__rrrrris ric@s(eZdZdZeZdZddZddZdS)_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typescCsRttjD]}t|ddri|_qtjdd|_|j |_t d|j |S)N__warningregistry__T)recordalways) listr!modulesvaluesgetattrr}warningscatch_warningswarnings_managerrk simplefilterrU)rvrrrrks  z_AssertWarnsContext.__enter__cCs|j||||durdSz |jj}WntyDt|j}Yn0d}|jD]Z}|j}t||jshqP|durt|}|j dur|j t|sqP||_ |j |_ |j |_ dS|dur|d|j jt||jr|d||jn|d|dS)Nrlz{} not triggered by {}z{} not triggered)rrwrUr rfr rmessager;r_rqZwarningfilenamelinenor[rmrrr`)rrsrtrurvZfirst_matchingmwrrrrws>       z_AssertWarnsContext.__exit__N) r r r rWarningrarcrkrwrrrrr|s  r|c@seZdZddZdS)_OrderedChainMapccs8t}|jD]&}|D]}||vr|||Vqq dSr))setmapsadd)rseenmappingkrrr__iter__,s   z_OrderedChainMap.__iter__N)r r r rrrrrr+src@seZdZdZeZdZdZdZdZ gZ dddZ d d Z d d Z ed dZddZddZeddZeddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zejefd)d*Z d+d,Z!d-d.Z"d/d0Z#d1d2Z$d3d4Z%d5d6Z&d7d8Z'dd:d;Z(dd?Z*d@dAZ+dBdCZ,dDdEZ-ddFdGZ.ddHdIZ/ddJdKZ0dLdMZ1dNdOZ2dPdQZ3ddRdSZ4dTdUZ5ddVdWZ6ddXdYZ7ddZd[Z8dd\d]Z9dd^d_Z:dd`daZ;dbdcZddhdiZ?ddjdkZ@ddldmZAddndoZBddpdqZCddrdsZDddtduZEddvdwZFddxdyZGddzd{ZHdd|d}ZIdd~dZJdddZKdddZLdddZMdddZNdddZOddZPddZQdddZRdddZSddZTeTe7ZUZVeTe8ZWZXeTe9ZYZZeTe:Z[Z\eTe0Z]Z^eTe2Z_eTe/Z`eTePZaeTeRZbeTeSZcd9S)TestCaseaWA class whose instances are single test cases. By default, the test code itself should be placed in a method named 'runTest'. If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute. Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test's environment ('fixture') can be implemented by overriding the 'setUp' and 'tearDown' methods respectively. If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run. When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when the instance's assertion methods fail; test methods raising this exception will be deemed to have 'failed' rather than 'errored'. * longMessage: determines whether long messages (including repr of objects used in assert methods) will be printed on failure in *addition* to any explicit message passed. * maxDiff: sets the maximum length of a diff in failure messages by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required. TiiFrunTestcCs||_d|_d|_zt||}Wn,tyL|dkrHtd|j|fYn 0|j|_g|_d|_ i|_ | t d| t d| td| td| td| td dS) zCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name. NzNo testrzno such test method in %s: %sassertDictEqualassertListEqualassertTupleEqualassertSetEqualassertMultiLineEqual)_testMethodName_outcome_testMethodDocrrf ValueError __class__r _cleanups_subtest_type_equality_funcsaddTypeEqualityFuncdictrrRr frozensetr )rZ methodName testMethodrrrrfs(       zTestCase.__init__cCs||j|<dS)a[Add a type specific assertEqual style function to compare a type. This method is for use by TestCase subclasses that need to register their own type equality functions to provide nicer error messages. Args: typeobj: The data type to call this function on when both values are of the same type in assertEqual(). function: The callable taking two arguments and an optional msg= argument that raises self.failureException with a useful error message when the two arguments are not equal. N)r)rZtypeobjr-rrrrs zTestCase.addTypeEqualityFunccOs|j|||fdS)aAdd a function, with arguments, to be called when the test is completed. Functions added are called on a LIFO basis and are called after tearDown on test failure or success. Cleanup items are called even if setUp fails (unlike tearDown).N)rrrr-r.r/rrr addCleanupszTestCase.addCleanupcOs|j|||fdS)zpSame as addCleanup, except the cleanup items are called even if setUpClass fails (unlike tearDownClass).N)_class_cleanupsrclsr-r.r/rrraddClassCleanupszTestCase.addClassCleanupcCsdS)zAHook method for setting up the test fixture before exercising it.NrrjrrrsetUpszTestCase.setUpcCsdS)zAHook method for deconstructing the test fixture after testing it.NrrjrrrtearDownszTestCase.tearDowncCsdS)zKHook method for setting up class fixture before running tests in the class.Nrrrrr setUpClassszTestCase.setUpClasscCsdS)zVHook method for deconstructing the class fixture after running all tests in the class.Nrrrrr tearDownClassszTestCase.tearDownClasscCsdS)NrrrjrrrcountTestCasesszTestCase.countTestCasescCstSr))rZ TestResultrjrrrdefaultTestResultszTestCase.defaultTestResultcCs$|j}|r |ddSdS)zReturns a one-line description of the test, or None if no description has been provided. The default implementation of this method returns the first line of the specified test method's docstring.  rN)rstripsplitrdocrrrshortDescriptionszTestCase.shortDescriptioncCsdt|j|jfS)Nz%s.%srrrrjrrridsz TestCase.idcCs t|t|urtS|j|jkSr))r<NotImplementedrrotherrrr__eq__szTestCase.__eq__cCstt||jfSr))hashr<rrjrrr__hash__szTestCase.__hash__cCsd|jt|jfSNz%s (%s))rrrrjrrr__str__szTestCase.__str__cCsdt|j|jfS)Nz<%s testMethod=%s>rrjrrr__repr__szTestCase.__repr__cCs<t|dd}|dur |||ntdtd||dS)NaddSkipz4TestResult has no addSkip method, skips not reported)rrwarnRuntimeWarning addSuccess)rrr#r9rrrr_addSkips  zTestCase._addSkipcks|jdus|jjsdVdS|j}|dur4t|}n |j|}t||||_zr|jj|jdddVWdn1s~0Y|jjs|jj }|dur|j rt n |jj rt W||_n||_0dS)aPReturn a context manager that will return the enclosed block of code in a subtest identified by the optional message and keyword parameters. A failure in the subtest marks the test case as failed but resumes execution at the end of the enclosed block, allowing further test code to be executed. NTr$) rrrrparams new_child_SubTestr&rrZfailfastrr)rrXrparentZ params_maprrrrsubTests$  $zTestCase.subTestcCs`|D]V\}}t|tr(||j||q|durt|d|jrN|||q|||qdS)Nr)r;rrr#rTrY addFailureZaddError)rrrtestr"rrr_feedErrorsToResults  zTestCase._feedErrorsToResultcCsBz |j}Wn(ty2tdt||Yn 0|||dS)Nz@TestResult has no addExpectedFailure method, reporting as passes)addExpectedFailurerfrrrr)rrr"rrrr_addExpectedFailure s  zTestCase._addExpectedFailurec Csdz |j}WnLtyVtdtz tdWn"tyP||tYn0Yn 0||dS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure) addUnexpectedSuccessrfrrrrrr!r")rrrrrr_addUnexpectedSuccesss    zTestCase._addUnexpectedSuccesscCs |dSr))rrjrrr _callSetUp"szTestCase._callSetUpcCs |dSr)r)rmethodrrr_callTestMethod%szTestCase._callTestMethodcCs |dSr))rrjrrr _callTearDown(szTestCase._callTearDowncOs||i|dSr)rrrrr _callCleanup+szTestCase._callCleanupNc Cs|dur8|}t|dd}t|dd}|dur<|nd}||z,t||j}t|jddspt|ddrt|jddpt|dd}|||||W|||dur|St|ddpt|dd}t|}zf||_| || Wdn1s 0Y|j r||_ |j |dd | |Wdn1sR0Yd|_ | ||Wdn1s0Y||jD]\}} |||| q|||j|j r|r|jr|||jn ||n |||W|jd|_d|_W|||dur>|S|jd|_d|_0W|||dur|n|||dur|0dS) N startTestRun stopTestRunr?Fr@rCrKTr)rrZ startTestrrrZstopTestrrr&rrrrr doCleanupsrrrrrrrclear) rrrrrskip_whyroutcomerr9rrrrun.s      ,    (* (           z TestCase.runcCsl|jp t}|jrf|j\}}}||(|j|g|Ri|Wdq 1sZ0Yq |jS)zNExecute all cleanup functions. Normally called for you after tearDown.N)rrrr1r&rr)rrr-r.r/rrrrqs   8zTestCase.doCleanupscCsXg|_|jrT|j\}}}z||i|WqtyP|jtYq0qdS)zYExecute all class cleanup functions. Normally called for you after tearDownClass.N)ZtearDown_exceptionsrr1r2rr!r"rrrrdoClassCleanups~s zTestCase.doClassCleanupscOs|j|i|Sr))r)rr.kwdsrrr__call__szTestCase.__call__cCst||j}t|jdds&t|ddrHt|jddp>t|dd}t||||||jr|j\}}}|j |g|Ri|qbdS)z6Run the test without collecting errors in a TestResultr?Fr@rCN) rrrr rrrrr1r)rrrr-r.r/rrrdebugs    zTestCase.debugcCs t|dS)zSkip this test.Nr6)rr9rrrskipTestszTestCase.skipTestcCs||dS)z)Fail immediately, with the given message.N)rY)rrXrrrfailsz TestCase.failcCs&|r"||dt|}||dS)z#Check that the expression is false.z%s is not falseNrWrrYrexprrXrrr assertFalseszTestCase.assertFalsecCs&|s"||dt|}||dS)z"Check that the expression is true.z%s is not trueNrrrrr assertTrueszTestCase.assertTruecCsT|js|p |S|dur|Szd||fWStyNdt|t|fYS0dS)aHonour the longMessage attribute when generating failure messages. If longMessage is False this means: * Use only an explicit message if it is provided * Otherwise use the standard message for the assert If longMessage is True: * Use the standard message * If an explicit message is provided, plus ' : ' and the explicit message Nz%s : %s) longMessageUnicodeDecodeErrorr)rrXrZrrrrWs  zTestCase._formatMessagecOs*t||}z|d||Wd}Sd}0dS)a=Fail unless an exception of class expected_exception is raised by the callable when invoked with specified positional and keyword arguments. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception. If called with the callable and arguments omitted, will return a context object used like this:: with self.assertRaises(SomeException): do_something() An optional keyword argument 'msg' can be provided when assertRaises is used as a context object. The context manager keeps a reference to the exception as the 'exception' attribute. This allows you to inspect the exception after the assertion:: with self.assertRaises(SomeException) as cm: do_something() the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) assertRaisesNrirh)rexpected_exceptionr.r/contextrrrrs  zTestCase.assertRaisescOst||}|d||S)aFail unless a warning of class warnClass is triggered by the callable when invoked with specified positional and keyword arguments. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception. If called with the callable and arguments omitted, will return a context object used like this:: with self.assertWarns(SomeWarning): do_something() An optional keyword argument 'msg' can be provided when assertWarns is used as a context object. The context manager keeps a reference to the first matching warning as the 'warning' attribute; similarly, the 'filename' and 'lineno' attributes give you information about the line of Python code from which the warning was triggered. This allows you to inspect the warning after the assertion:: with self.assertWarns(SomeWarning) as cm: do_something() the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) assertWarnsr|rh)rexpected_warningr.r/rrrrrs zTestCase.assertWarnscCsddlm}||||S)aFail unless a log message of level *level* or higher is emitted on *logger_name* or its children. If omitted, *level* defaults to INFO and *logger* defaults to the root logger. This method must be used as a context manager, and will yield a recording object with two attributes: `output` and `records`. At the end of the context manager, the `output` attribute will be a list of the matching formatted log messages and the `records` attribute will be a list of the corresponding LogRecord objects. Example:: with self.assertLogs('foo', level='INFO') as cm: logging.getLogger('foo').info('first message') logging.getLogger('foo.bar').error('second message') self.assertEqual(cm.output, ['INFO:foo:first message', 'ERROR:foo.bar:second message']) r)_AssertLogsContext)Z_logr)rZloggerlevelrrrr assertLogss zTestCase.assertLogscCsFt|t|ur@|jt|}|dur@t|tr.z; zMismatched values: %s) rrDeprecationWarningitemsrrrrrW) rZsubsetZ dictionaryrXZmissingZ mismatchedkeyvaluerZrrrassertDictContainsSubsetrs4      z!TestCase.assertDictContainsSubsetc Cst|t|}}zt|}t|}WntyFt||}Yn0||krTdSt||}|rd}dd|D}d|} ||| }|||}| |dS)a[Asserts that two iterables have the same elements, the same number of times, without regard to order. self.assertEqual(Counter(list(first)), Counter(list(second))) Example: - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal. NzElement counts were not equal: cSsg|] }d|qS)z First has %d, Second has %d: %rr)rMr rrr rQz-TestCase.assertCountEqual..r) r collectionsCounterrbrrrrrWr) rrrrXZ first_seqZ second_seqZ differencesrZr%rrrrassertCountEquals       zTestCase.assertCountEqualcCs||td||td||krt||jks@t||jkrN|||||jdd}|jdd}t|dkr|d|kr|dg}|dg}dt||}dd t ||}| ||}| | ||d S) z-Assert that two multi-line strings are equal.zFirst argument is not a stringzSecond argument is not a stringT)keependsrz rrrCN)r/r r_diffThresholdrrrrrrrrrrW)rrrrXZ firstlinesZ secondlinesrZr rrrrs       zTestCase.assertMultiLineEqualcCs2||ks.dt|t|f}||||dS)zCJust like self.assertTrue(a < b), but with a nicer default message.z%s not less than %sNr'rabrXrZrrr assertLessszTestCase.assertLesscCs2||ks.dt|t|f}||||dS)zDJust like self.assertTrue(a <= b), but with a nicer default message.z%s not less than or equal to %sNr'r<rrrassertLessEqualszTestCase.assertLessEqualcCs2||ks.dt|t|f}||||dS)zCJust like self.assertTrue(a > b), but with a nicer default message.z%s not greater than %sNr'r<rrr assertGreaterszTestCase.assertGreatercCs2||ks.dt|t|f}||||dS)zDJust like self.assertTrue(a >= b), but with a nicer default message.z"%s not greater than or equal to %sNr'r<rrrassertGreaterEqualszTestCase.assertGreaterEqualcCs,|dur(dt|f}||||dS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz%s is not Noner'rr*rXrZrrr assertIsNoneszTestCase.assertIsNonecCs"|durd}||||dS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)rrWrCrrrassertIsNotNoneszTestCase.assertIsNotNonecCs0t||s,dt||f}||||dS)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer default message.z%s is not an instance of %rNr;rrrWrr*rrXrZrrrr/s zTestCase.assertIsInstancecCs0t||r,dt||f}||||dS)z,Included for symmetry with assertIsInstance.z%s is an instance of %rNrFrGrrrassertNotIsInstances zTestCase.assertNotIsInstancecOst|||}|d||S)aAsserts that the message in a raised exception matches a regex. Args: expected_exception: Exception class expected to be raised. expected_regex: Regex (re.Pattern object or string) expected to be found in error message. args: Function to be called and extra positional args. kwargs: Extra kwargs. msg: Optional message used in case of failure. Can only be used when assertRaisesRegex is used as a context manager. assertRaisesRegexr)rrr_r.r/rrrrrIs zTestCase.assertRaisesRegexcOst|||}|d||S)aAsserts that the message in a triggered warning matches a regexp. Basic functioning is similar to assertWarns() with the addition that only warnings whose messages also match the regular expression are considered successful matches. Args: expected_warning: Warning class expected to be triggered. expected_regex: Regex (re.Pattern object or string) expected to be found in error message. args: Function to be called and extra positional args. kwargs: Extra kwargs. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. assertWarnsRegexr)rrr_r.r/rrrrrJs zTestCase.assertWarnsRegexcCsJt|ttfrt|}||sFd|j|f}|||}||dS)z=Fail the test unless the text matches the regular expression.z&Regex didn't match: %r not found in %rN) r;r bytesr]r^rqrrrWrY)rtextr_rXrZrrr assertRegexs   zTestCase.assertRegexcCs`t|ttfrt|}||}|r\d||||j|f}| ||}| |dS)z9Fail the test if the text matches the regular expression.z"Regex matched: %r matches %r in %rN) r;r rKr]r^rqstartendrrrWrY)rrLZunexpected_regexrXmatchrZrrrassertNotRegex#s   zTestCase.assertNotRegexcsfdd}|S)Ncs$tdjtd|i|S)NzPlease use {0} instead.r)rrrmr r1r7 original_funcrrdeprecated_func3s  z,TestCase._deprecate..deprecated_funcr)rSrTrrRr _deprecate2s zTestCase._deprecate)r)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)dr r r rAssertionErrorrYrr r;Z_classSetupFailedrrrrryrrrrrrrrrrrrrrr'r(_subtest_msg_sentinelrrrrrrrrrrrrrrrrrrWrrrrrrrr rrrrrrr*r+r-r.rr5r9rr?r@rArBrDrEr/rHrIrJrMrQrUZfailUnlessEqualZ assertEqualsZ failIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrr5s          C     !     - # c +                    rcsjeZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ZS)FunctionTestCaseaIA test case that wraps a test function. This is useful for slipping pre-existing test functions into the unittest framework. Optionally, set-up and tidy-up functions can be supplied. As with TestCase, the tidy-up ('tearDown') function will always be called if the set-up ('setUp') function ran successfully. Ncs*tt|||_||_||_||_dSr))superrXr _setUpFunc _tearDownFunc _testFunc _description)rZtestFuncrrZ descriptionrrrrQs zFunctionTestCase.__init__cCs|jdur|dSr))rZrjrrrrXs zFunctionTestCase.setUpcCs|jdur|dSr))r[rjrrrr\s zFunctionTestCase.tearDowncCs |dSr))r\rjrrrr`szFunctionTestCase.runTestcCs|jjSr))r\r rjrrrrcszFunctionTestCase.idcCs@t||jstS|j|jko>|j|jko>|j|jko>|j|jkSr))r;rrrZr[r\r]rrrrrfs     zFunctionTestCase.__eq__cCstt||j|j|j|jfSr))rr<rZr[r\r]rjrrrroszFunctionTestCase.__hash__cCsdt|j|jjfSr)rrr\r rjrrrrss zFunctionTestCase.__str__cCsdt|j|jfS)Nz <%s tec=%s>)rrr\rjrrrrws zFunctionTestCase.__repr__cCs2|jdur|jS|jj}|r.|ddp0dS)Nrr)r]r\rrrrrrrr{s z!FunctionTestCase.shortDescription)NNN)r r r rrrrrrrrrrr __classcell__rrr^rrXHs rXcsDeZdZfddZddZddZddZd d Zd d ZZ S) rcs(t||_||_||_|j|_dSr))rYr_messager#rrY)rr#rrr^rrrs  z_SubTest.__init__cCs tddS)Nzsubtests cannot be run directly)rrjrrrrsz_SubTest.runTestcCs^g}|jtur |d|j|jrPddd|jD}|d|d|p\dS)Nz[{}]z, css|]\}}d||VqdS)z{}={!r}N)rm)rMrrrrrrPsz+_SubTest._subDescription..z({}) z ())r`rWrrmrrr2)rpartsZ params_descrrr_subDescriptions  z_SubTest._subDescriptioncCsd|j|SNz{} {})rmr#rrcrjrrrrsz _SubTest.idcCs |jS)zlReturns a one-line description of the subtest, or None if no description has been provided. )r#rrjrrrrsz_SubTest.shortDescriptioncCsd|j|Srd)rmr#rcrjrrrrsz_SubTest.__str__) r r r rrrcrrrr_rrr^rrs   r).rr!r=rrr]rr7r'rnrDrCrutilrrrrrZ __unittestobjectrWr!r2r rrrr+r,r0r5rFrIrJrrLrVr\rir|ChainMaprrrXrrrrrsX ( *'5 :