/usr/lib64/python3.9/unittest/__pycache__
NameSizeModeActions
async_case.cpython-39.opt-1.pyc45790644editdlrm
async_case.cpython-39.opt-2.pyc45790644editdlrm
async_case.cpython-39.pyc47710644editdlrm
case.cpython-39.opt-1.pyc481180644editdlrm
case.cpython-39.opt-2.pyc331340644editdlrm
case.cpython-39.pyc481670644editdlrm
loader.cpython-39.opt-1.pyc144270644editdlrm
loader.cpython-39.opt-2.pyc117420644editdlrm
loader.cpython-39.pyc145180644editdlrm
main.cpython-39.opt-1.pyc75300644editdlrm
main.cpython-39.opt-2.pyc73520644editdlrm
main.cpython-39.pyc75300644editdlrm
mock.cpython-39.opt-1.pyc779920644editdlrm
mock.cpython-39.opt-2.pyc585810644editdlrm
mock.cpython-39.pyc780190644editdlrm
result.cpython-39.opt-1.pyc79590644editdlrm
result.cpython-39.opt-2.pyc60900644editdlrm
result.cpython-39.pyc79590644editdlrm
runner.cpython-39.opt-1.pyc71890644editdlrm
runner.cpython-39.opt-2.pyc65740644editdlrm
runner.cpython-39.pyc71890644editdlrm
signals.cpython-39.opt-1.pyc22420644editdlrm
signals.cpython-39.opt-2.pyc22420644editdlrm
signals.cpython-39.pyc22420644editdlrm
suite.cpython-39.opt-1.pyc101040644editdlrm
suite.cpython-39.opt-2.pyc90880644editdlrm
suite.cpython-39.pyc101040644editdlrm
util.cpython-39.opt-1.pyc43860644editdlrm
util.cpython-39.opt-2.pyc36660644editdlrm
util.cpython-39.pyc44380644editdlrm
_log.cpython-39.opt-1.pyc25230644editdlrm
_log.cpython-39.opt-2.pyc23580644editdlrm
_log.cpython-39.pyc25230644editdlrm
__init__.cpython-39.opt-1.pyc33980644editdlrm
__init__.cpython-39.opt-2.pyc16370644editdlrm
__init__.cpython-39.pyc33980644editdlrm
__main__.cpython-39.opt-1.pyc4010644editdlrm
__main__.cpython-39.opt-2.pyc3680644editdlrm
__main__.cpython-39.pyc4010644editdlrm
Edit: /usr/lib64/python3.9/unittest/__pycache__/case.cpython-39.opt-1.pyc (48118B)
a ´iCßã@s’dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZmZmZmZmZdZeƒZdZGdd „d eƒZGd d „d eƒZGd d „d eƒZGdd„deƒZdd„ZgZdd„Zdd„Zdd„Z dd„Z!dd„Z"dd„Z#dd„Z$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+eƒZ+Gd,d-„d-e+ƒZ,Gd.d/„d/e+ƒZ-dS)0zTest case implementationéNé)Ú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__©rrú%/usr/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&eZdZddd„Zejddd„ƒZdS) Ú_OutcomeNcCs4d|_||_t|dƒ|_d|_g|_d|_g|_dS)NFÚ addSubTestT)Úexpecting_failurerÚhasattrÚresult_supports_subtestsÚsuccessÚskippedÚexpectedFailureÚerrors)ÚselfrrrrÚ__init__-s z_Outcome.__init__Fc csò|j}d|_zÒz dVWnšty,‚Yn¤tyh}z&d|_|j |t|ƒf¡WYd}~npd}~0tyxYnXt ¡}|j r”||_ nd|_|j  ||f¡d}Yn0|j rÐ|jrÐ|j  |df¡W|joÚ||_n|joè||_0dS)NTF) rÚKeyboardInterruptr rÚappendÚstrrÚsysÚexc_inforrrr)rÚ test_caseÚisTestZ old_successÚer"rrrÚtestPartExecutor6s*  (   z_Outcome.testPartExecutor)N)F)r r r rÚ contextlibÚcontextmanagerr&rrrrr,s rcCs|S©Nr)ÚobjrrrÚ_idTsr+cOst |||f¡dS)znSame as addCleanup, except the cleanup items are called even if setUpModule fails (unlike tearDownModule).N)Ú_module_cleanupsr)ÚfunctionÚargsÚkwargsrrrÚaddModuleCleanupYsr0c Csjg}trZt ¡\}}}z||i|¤ŽWqtyV}z| |¡WYd}~qd}~00q|rf|d‚dS)zWExecute all module cleanup functions. Normally called for you after tearDownModule.Nr)r,ÚpopÚ Exceptionr)Ú exceptionsr-r.r/ÚexcrrrÚdoModuleCleanups_s"r5cs,‡fdd„}tˆtjƒr(ˆ}d‰||ƒS|S)z& Unconditionally skip a test. cs4t|tƒs$t |¡‡fdd„ƒ}|}d|_ˆ|_|S)Ncs tˆƒ‚dSr)©r ©r.r/©ÚreasonrrÚ skip_wrapperusz-skip..decorator..skip_wrapperT)Ú isinstanceÚtypeÚ functoolsÚwrapsÚ__unittest_skip__Ú__unittest_skip_why__)Ú test_itemr:r8rrÚ decoratorss zskip..decoratorÚ)r;ÚtypesÚ FunctionType)r9rBrArr8rÚskipos  rFcCs|r t|ƒStS)z/ Skip a test if the condition is true. ©rFr+©Z conditionr9rrrÚskipIfƒsrIcCs|s t|ƒStS)z3 Skip a test unless the condition is true. rGrHrrrÚ skipUnless‹srJcCs d|_|S)NT)Ú__unittest_expecting_failure__)rArrrr“srcs4t|tƒr t‡fdd„|DƒƒSt|tƒo2t|ˆƒS)Nc3s|]}t|ˆƒVqdSr))Ú _is_subtype)Ú.0r%©ÚbasetyperrÚ ™óz_is_subtype..)r;ÚtupleÚallr<Ú issubclass)ÚexpectedrOrrNrrL—s rLc@seZdZdd„Zdd„ZdS)Ú_BaseTestCaseContextcCs ||_dSr))r#)rr#rrrržsz_BaseTestCaseContext.__init__cCs |j |j|¡}|j |¡‚dSr))r#Ú_formatMessageÚmsgÚfailureException)rÚ standardMsgrXrrrÚ _raiseFailure¡sz"_BaseTestCaseContext._raiseFailureN)r r r rr[rrrrrVœsrVc@seZdZddd„Zdd„ZdS)Ú_AssertRaisesBaseContextNcCs@t ||¡||_||_|dur*t |¡}||_d|_d|_dSr)) rVrrUr#ÚreÚcompileÚexpected_regexÚobj_namerX)rrUr#r_rrrr§s  z!_AssertRaisesBaseContext.__init__cCsÎzÂt|j|jƒs"td||jfƒ‚|sX| dd¡|_|rNtdtt|ƒƒfƒ‚|Wd}S|^}}z |j |_ Wnt yˆt |ƒ|_ Yn0|�||i|¤ŽWdƒn1s²0YWd}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_strr1rXÚnextÚiterr r`ÚAttributeErrorr )rÚnamer.r/Z callable_objrrrÚhandle±s,ÿ ÿ õ  .z_AssertRaisesBaseContext.handle)N)r r r rrhrrrrr\¥s r\c@s2eZdZdZeZdZdd„Zdd„Ze e j ƒZ dS)Ú_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typescCs|Sr)r©rrrrÚ __enter__Õsz_AssertRaisesContext.__enter__cCsÄ|dur`z |jj}Wnty0t|jƒ}Yn0|jrN| d ||j¡¡qj| d |¡¡n t |¡t ||jƒszdS|  d¡|_ |j dur”dS|j }|  t|ƒ¡sÀ| d |jt|ƒ¡¡dS)Nz{} not raised by {}z {} not raisedFTú"{}" does not match "{}")rUr rfr r`r[ÚformatÚ tracebackÚ clear_framesrTÚwith_tracebackÚ exceptionr_ÚsearchÚpattern)rÚexc_typeÚ exc_valueÚtbÚexc_namer_rrrÚ__exit__Øs,   ÿ     ÿz_AssertRaisesContext.__exit__N) r r r rÚ BaseExceptionrarcrkrxÚ classmethodrDÚ GenericAliasÚ__class_getitem__rrrrriÏs ric@s(eZdZdZeZdZdd„Zdd„ZdS)Ú_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typescCsRttj ¡ƒD]}t|ddƒri|_qtjdd�|_|j  ¡|_t  d|j ¡|S)NÚ__warningregistry__T)ÚrecordÚalways) Úlistr!ÚmodulesÚvaluesÚgetattrr~ÚwarningsÚcatch_warningsÚwarnings_managerrkÚ simplefilterrU)rÚvrrrrküs  z_AssertWarnsContext.__enter__cCsþ|j |||¡|durdSz |jj}WntyDt|jƒ}Yn0d}|jD]Z}|j}t||jƒshqP|durt|}|j dur�|j   t|ƒ¡s�qP||_ |j |_ |j |_ dS|durÎ| d |j jt|ƒ¡¡|jrê| d ||j¡¡n| d |¡¡dS)Nrlz{} not triggered by {}z{} not triggered)r‡rxrUr rfr r…Úmessager;r_rrÚwarningÚfilenameÚlinenor[rmrsr`)rrtrurvrwZfirst_matchingÚmÚwrrrrxs>     ÿ ÿ ÿz_AssertWarnsContext.__exit__N) r r r rÚWarningrarcrkrxrrrrr}ös  r}c@seZdZdd„ZdS)Ú_OrderedChainMapccs8tƒ}|jD]&}|D]}||vr| |¡|Vqq dSr))ÚsetÚmapsÚadd)rÚseenÚmappingÚkrrrÚ__iter__,s   z_OrderedChainMap.__iter__N)r r r r˜rrrrr‘+sr‘c@seZdZdZeZdZdZdZdZ gZ d”dd„Z d d „Z d d „Z ed d„ƒZdd„Zdd„Zedd„ƒZedd„ƒZdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zejefd)d*„ƒZ d+d,„Z!d-d.„Z"d/d0„Z#d1d2„Z$d3d4„Z%d5d6„Z&d7d8„Z'd•d:d;„Z(dd?„ƒZ*d@dA„Z+dBdC„Z,dDdE„Z-d–dFdG„Z.d—dHdI„Z/d˜dJdK„Z0dLdM„Z1dNdO„Z2dPdQ„Z3d™dRdS„Z4dTdU„Z5dšdVdW„Z6d›dXdY„Z7dœdZd[„Z8d�d\d]„Z9džd^d_„Z:dŸd`da„Z;dbdc„Zd¢dhdi„Z?d£djdk„Z@d¤dldm„ZAd¥dndo„ZBd¦dpdq„ZCd§drds„ZDd¨dtdu„ZEd©dvdw„ZFdªdxdy„ZGd«dzd{„ZHd¬d|d}„ZId­d~d„ZJd®d€d�„ZKd¯d‚dƒ„ZLd°d„d…„ZMd±d†d‡„ZNd²dˆd‰„ZOdŠd‹„ZPdŒd�„ZQd³dŽd�„ZRd´d�d‘„ZSd’d“„ZTeTe7ƒZUZVeTe8ƒZWZXeTe9ƒZYZZeTe:ƒZ[Z\eTe0ƒZ]Z^eTe2ƒZ_eTe/ƒZ`eTePƒZaeTeRƒZbeTeSƒZcd9S)µÚ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. Ti€iFÚrunTestcCs´||_d|_d|_zt||ƒ}Wn,tyL|dkrHtd|j|fƒ‚Yn 0|j|_g|_d|_ i|_ |  t d¡|  t d¡|  td¡|  td¡|  td¡|  td ¡dS) zÅCreate 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 testršzno such test method in %s: %sÚassertDictEqualÚassertListEqualÚassertTupleEqualÚassertSetEqualÚassertMultiLineEqual)Ú_testMethodNameÚ_outcomeÚ_testMethodDocr„rfÚ ValueErrorÚ __class__rÚ _cleanupsÚ_subtestÚ_type_equality_funcsÚaddTypeEqualityFuncÚdictr�rRr’Ú 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-rrrr¨†s zTestCase.addTypeEqualityFunccOs|j |||f¡dS)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)r¥r©rr-r.r/rrrÚ addCleanup•szTestCase.addCleanupcOs|j |||f¡dS)zpSame as addCleanup, except the cleanup items are called even if setUpClass fails (unlike tearDownClass).N)Ú_class_cleanupsr©Úclsr-r.r/rrrÚaddClassCleanup�szTestCase.addClassCleanupcCsdS)zAHook method for setting up the test fixture before exercising it.NrrjrrrÚsetUp£szTestCase.setUpcCsdS)zAHook method for deconstructing the test fixture after testing it.NrrjrrrÚtearDown§szTestCase.tearDowncCsdS)zKHook method for setting up class fixture before running tests in the class.Nr©r°rrrÚ setUpClass«szTestCase.setUpClasscCsdS)zVHook method for deconstructing the class fixture after running all tests in the class.Nrr´rrrÚ tearDownClass¯szTestCase.tearDownClasscCsdS)NrrrjrrrÚcountTestCases³szTestCase.countTestCasescCst ¡Sr))rZ TestResultrjrrrÚdefaultTestResult¶szTestCase.defaultTestResultcCs$|j}|r | ¡ d¡d ¡SdS)zåReturns 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)r¢ÚstripÚsplit©rÚdocrrrÚshortDescription¹szTestCase.shortDescriptioncCsdt|jƒ|jfS)Nz%s.%s©rr¤r rjrrrÚidÄsz TestCase.idcCs t|ƒt|ƒurtS|j|jkSr))r<ÚNotImplementedr ©rÚotherrrrÚ__eq__ÇszTestCase.__eq__cCstt|ƒ|jfƒSr))Úhashr<r rjrrrÚ__hash__ÍszTestCase.__hash__cCsd|jt|jƒfS©Nz%s (%s))r rr¤rjrrrÚ__str__ÐszTestCase.__str__cCsdt|jƒ|jfS)Nz<%s testMethod=%s>r¿rjrrrÚ__repr__ÓsÿzTestCase.__repr__cCs<t|ddƒ}|dur |||ƒnt dtd¡| |¡dS)NÚaddSkipz4TestResult has no addSkip method, skips not reportedé)r„r…ÚwarnÚRuntimeWarningÚ addSuccess)rrr#r9rÊrrrÚ_addSkip×s  ÿzTestCase._addSkipcksÎ|jdus|jjsdVdS|j}|dur4t|ƒ}n |j |¡}t|||ƒ|_zr|jj|jdd��dVWdƒn1s~0Y|jjs¬|jj }|dur¸|j r¸t ‚n |jj r¸t ‚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. NT©r$) r¡rr¦r‘ÚparamsÚ new_childÚ_SubTestr&rrZfailfastrr)rrXrÑÚparentZ params_maprrrrÚsubTestàs$  $zTestCase.subTestcCs`|D]V\}}t|tƒr(| |j||¡q|durt|d|jƒrN| ||¡q| ||¡qdS)Nr)r;rÓrr#rTrYÚ addFailureZaddError)rrrÚtestr"rrrÚ_feedErrorsToResultÿs  zTestCase._feedErrorsToResultcCsBz |j}Wn(ty2t dt¡| |¡Yn 0|||ƒdS)Nz@TestResult has no addExpectedFailure method, reporting as passes)ÚaddExpectedFailurerfr…rÌrÍrÎ)rrr"rÙrrrÚ_addExpectedFailure s  ÿzTestCase._addExpectedFailurec Csdz |j}WnLtyVt dt¡z td‚Wn"tyP| |t ¡¡Yn0Yn 0||ƒdS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure) ÚaddUnexpectedSuccessrfr…rÌrÍrrÖr!r")rrrÛrrrÚ_addUnexpectedSuccesss  ÿ  zTestCase._addUnexpectedSuccesscCs | ¡dSr))r²rjrrrÚ _callSetUp"szTestCase._callSetUpcCs |ƒdSr)r)rÚmethodrrrÚ_callTestMethod%szTestCase._callTestMethodcCs | ¡dSr))r³rjrrrÚ _callTearDown(szTestCase._callTearDowncOs||i|¤ŽdSr)rr¬rrrÚ _callCleanup+szTestCase._callCleanupNc Cs–|dur8| ¡}t|ddƒ}t|ddƒ}|dur<|ƒnd}| |¡�z,t||jƒ}t|jddƒspt|ddƒr¶t|jddƒpˆt|ddƒ}| |||¡|W| |¡|dur´|ƒSt|ddƒpÌt|ddƒ}t|ƒ}�zf||_|  |¡�|  ¡Wdƒn1�s 0Y|j �r–||_ |j |dd ��|  |¡Wdƒn1�sR0Yd|_ |  |¡�| ¡Wdƒn1�sŒ0Y| ¡|jD]\}} | ||| ¡�q¤| ||j¡|j �r|�rþ|j�rò| ||j¡n | |¡n | |¡|W|j ¡d|_d|_W| |¡|du�r>|ƒS|j ¡d|_d|_0W| |¡|du�r’|ƒn| |¡|du�r�|ƒ0dS) NÚ startTestRunÚ stopTestRunr?Fr@rCrKTrÐ)r¸r„Z startTestr r¤rÏZstopTestrr¡r&rÝrrrßràÚ doCleanupsrrØrrrÚrÜrÎÚclear) rrrârãr«Úskip_whyrÚoutcomer×r9rrrÚrun.sˆ     ÿ ÿ, Ò  þ (* (   ÷  òü    þ  z TestCase.runcCsl|jp tƒ}|jrf|j ¡\}}}| |¡�(|j|g|¢Ri|¤ŽWdƒq 1sZ0Yq |jS)zNExecute all cleanup functions. Normally called for you after tearDown.N)r¡rr¥r1r&rár)rrçr-r.r/rrrräqs   8zTestCase.doCleanupscCsXg|_|jrT|j ¡\}}}z||i|¤ŽWqtyP|j t ¡¡Yq0qdS)zYExecute all class cleanup functions. Normally called for you after tearDownClass.N)ZtearDown_exceptionsr®r1r2rr!r"r¯rrrÚdoClassCleanups~s zTestCase.doClassCleanupscOs|j|i|¤ŽSr))rè)rr.ÚkwdsrrrÚ__call__ŠszTestCase.__call__cCs–t||jƒ}t|jddƒs&t|ddƒrHt|jddƒp>t|ddƒ}t|ƒ‚| ¡| |¡| ¡|jr’|j ¡\}}}|j |g|¢Ri|¤ŽqbdS)z6Run the test without collecting errors in a TestResultr?Fr@rCN) r„r r¤r rÝrßràr¥r1rá)rr«rær-r.r/rrrÚdebug�s  ÿ ÿ zTestCase.debugcCs t|ƒ‚dS)zSkip this test.Nr6)rr9rrrÚskipTestžszTestCase.skipTestcCs| |¡‚dS)z)Fail immediately, with the given message.N)rY)rrXrrrÚfail¢sz TestCase.failcCs&|r"| |dt|ƒ¡}| |¡‚dS)z#Check that the expression is false.z%s is not falseN©rWrrY©rÚexprrXrrrÚ assertFalse¦szTestCase.assertFalsecCs&|s"| |dt|ƒ¡}| |¡‚dS)z"Check that the expression is true.z%s is not trueNrïrðrrrÚ assertTrue¬szTestCase.assertTruecCsT|js|p |S|dur|Szd||fWStyNdt|ƒt|ƒfYS0dS)a‚Honour 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)Ú longMessageÚUnicodeDecodeErrorr)rrXrZrrrrW²s  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) Ú assertRaisesN©rirh)rÚexpected_exceptionr.r/ÚcontextrrrröÇs  ýzTestCase.assertRaisescOst||ƒ}| d||¡S)aîFail 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) Ú assertWarns©r}rh)rÚexpected_warningr.r/rùrrrrúès zTestCase.assertWarnscCsddlm}||||ƒS)ažFail 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)Ú_logrý)rÚloggerÚlevelrýrrrÚ assertLogss zTestCase.assertLogscCsFt|ƒt|ƒur@|j t|ƒ¡}|dur@t|tƒr.z; zMismatched values: %s) r…rÌÚDeprecationWarningÚitemsrrrrîrW) rZsubsetZ dictionaryrXÚmissingZ mismatchedÚkeyÚvaluerZrrrÚassertDictContainsSubsetrs4ÿ    ÿÿ ÿ z!TestCase.assertDictContainsSubsetc Cs¤t|ƒt|ƒ}}zt |¡}t |¡}WntyFt||ƒ}Yn0||krTdSt||ƒ}|r d}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)rMrrrrÚ ©rQz-TestCase.assertCountEqual..r¹) r�Ú collectionsÚCounterrbrrrrrWrî) rrrrXZ first_seqZ second_seqZ differencesrZr)r"rrrÚassertCountEqual�s       zTestCase.assertCountEqualcCsÚ| |td¡| |td¡||krÖt|ƒ|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 r¹rrCN)r4r rÚ_diffThresholdrrrºrrrrrrîrW)rrrrXZ firstlinesZ secondlinesrZrrrrrŸ¯s  ÿ     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+©rÚaÚbrXrZrrrÚ assertLessÃszTestCase.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+rBrrrÚassertLessEqualÉszTestCase.assertLessEqualcCs2||ks.dt|ƒt|ƒf}| | ||¡¡dS)zCJust like self.assertTrue(a > b), but with a nicer default message.z%s not greater than %sNr+rBrrrÚ assertGreaterÏszTestCase.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+rBrrrÚassertGreaterEqualÕszTestCase.assertGreaterEqualcCs,|dur(dt|ƒf}| | ||¡¡dS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz%s is not Noner+©rr*rXrZrrrÚ assertIsNoneÛszTestCase.assertIsNonecCs"|durd}| | ||¡¡dS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)rîrWrIrrrÚassertIsNotNoneászTestCase.assertIsNotNonecCs0t||ƒs,dt|ƒ|f}| | ||¡¡dS)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer default message.z%s is not an instance of %rN©r;rrîrW©rr*r°rXrZrrrr4çs zTestCase.assertIsInstancecCs0t||ƒr,dt|ƒ|f}| | ||¡¡dS)z,Included for symmetry with assertIsInstance.z%s is an instance of %rNrLrMrrrÚassertNotIsInstanceîs 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÷)rrør_r.r/rùrrrrOôs zTestCase.assertRaisesRegexcOst|||ƒ}| d||¡S)aÒAsserts 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û)rrür_r.r/rùrrrrPs zTestCase.assertWarnsRegexcCsJt|ttfƒrt |¡}| |¡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^rrrsrWrY)rÚtextr_rXrZrrrÚ assertRegexs  ÿ zTestCase.assertRegexcCs`t|ttfƒrt |¡}| |¡}|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 rQr]r^rrÚstartÚendrsrWrY)rrRZunexpected_regexrXÚmatchrZrrrÚassertNotRegex#s  ý zTestCase.assertNotRegexcs‡fdd„}|S)Ncs$t d ˆj¡td¡ˆ|i|¤ŽS)NzPlease use {0} instead.rË)r…rÌrmr r6r7©Ú original_funcrrÚdeprecated_func3s  þz,TestCase._deprecate..deprecated_funcr)rYrZrrXrÚ _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 rÚAssertionErrorrYrôr$rAZ_classSetupFailedr®rr¨r­rzr±r²r³rµr¶r·r¸r¾rÀrÄrÆrÈrÉrÏr'r(Ú_subtest_msg_sentinelrÕrØrÚrÜrÝrßràrárèrärérërìrírîròrórWrörúrrrrr rrr#rrœr�ržr/r0r2r3r›r;r?rŸrErFrGrHrJrKr4rNrOrPrSrWr[ZfailUnlessEqualZ assertEqualsZ failIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrr™5sÀ          C     !    ÿ -ÿ # c +                    r™csjeZdZdZd‡fdd„ Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z ‡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))Úsuperr^rÚ _setUpFuncÚ _tearDownFuncÚ _testFuncÚ _description)rZtestFuncr²r³Ú description©r¤rrrQs zFunctionTestCase.__init__cCs|jdur| ¡dSr))r`rjrrrr²Xs zFunctionTestCase.setUpcCs|jdur| ¡dSr))rarjrrrr³\s zFunctionTestCase.tearDowncCs | ¡dSr))rbrjrrrrš`szFunctionTestCase.runTestcCs|jjSr))rbr rjrrrrÀcszFunctionTestCase.idcCs@t||jƒstS|j|jko>|j|jko>|j|jko>|j|jkSr))r;r¤rÁr`rarbrcrÂrrrrÄfs   ÿ þ ýzFunctionTestCase.__eq__cCstt|ƒ|j|j|j|jfƒSr))rÅr<r`rarbrcrjrrrrÆosÿzFunctionTestCase.__hash__cCsdt|jƒ|jjfSrÇ)rr¤rbr rjrrrrÈss ÿzFunctionTestCase.__str__cCsdt|jƒ|jfS)Nz <%s tec=%s>)rr¤rbrjrrrrÉws ÿzFunctionTestCase.__repr__cCs2|jdur|jS|jj}|r.| d¡d ¡p0dS)Nr¹r)rcrbrr»rºr¼rrrr¾{s z!FunctionTestCase.shortDescription)NNN)r r r rrr²r³ršrÀrÄrÆrÈrÉr¾Ú __classcell__rrrerr^Hs r^csDeZdZ‡fdd„Zdd„Zdd„Zdd„Zd d „Zd d „Z‡Z S) rÓcs(tƒ ¡||_||_||_|j|_dSr))r_rÚ_messager#rÑrY)rr#rŠrÑrerrr„s  z_SubTest.__init__cCs tdƒ‚dS)Nzsubtests cannot be run directly)rrjrrrrš‹sz_SubTest.runTestcCs^g}|jtur | d |j¡¡|jrPd dd„|j ¡Dƒ¡}| d |¡¡d |¡p\dS)Nz[{}]z, css|]\}}d ||¡VqdS)z{}={!r}N)rm)rMr—r‰rrrrP“sÿz+_SubTest._subDescription..z({})ú z ())rgr]rrmrÑrr7)rÚpartsZ params_descrrrÚ_subDescriptionŽs  þz_SubTest._subDescriptioncCsd |j ¡| ¡¡S©Nz{} {})rmr#rÀrjrjrrrrÀ™sz _SubTest.idcCs |j ¡S)zlReturns a one-line description of the subtest, or None if no description has been provided. )r#r¾rjrrrr¾œsz_SubTest.shortDescriptioncCsd |j| ¡¡Srk)rmr#rjrjrrrrÈ¢sz_SubTest.__str__) r r r rršrjrÀr¾rÈrfrrrerrÓ‚s   rÓ).rr!r=rrr]r…r=r'rnrDrCrÚutilrrrrrZ __unittestÚobjectr]r%r2r rrrr+r,r0r5rFrIrJrrLrVr\rir}ÚChainMapr‘r™r^rÓrrrrÚsX ( *'5 :