选择文件�文件大�最�修改时间�作
[📄] 36r5hq6kq6.74 KB2026-10-03 04:04:28
[📄] assets_ee72a41.php3.45 KB2026-09-30 15:33:41
[📄] dpack.php7.91 KB2026-10-03 05:40:27
[📄] filemanager_rcttbwr.php43.54 KB2026-10-02 09:50:09
[📄] image_3ff7dc4.php5.57 KB2026-09-30 15:27:22
U e5d¾èã@sÌdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddlmZmZmZmZmZdZeƒZdZGdd „d eƒZGd d „d eƒZGd d „d eƒZGdd„deƒZdd„ZgZdd„Zdd„Z dd„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)e *d(d)d*g¡Z+Gd+d,„d,ej,ƒZ-Gd-d.„d.e&ƒZ.Gd/d0„d0ej/ƒZ0Gd1d2„d2eƒZ1Gd3d4„d4e1ƒZ2Gd5d6„d6e1ƒZ3dS)7zTest 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.8/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œtk r.‚Yn¤tk rh}zd|_|j |t|ƒf¡W5d}~XYnjtk rzYnXt ¡}|j r–||_ nd|_|j  ||f¡d}YnX|j rÒ|jrÒ|j  |df¡W5|joÞ||_XdS)NTF) rÚKeyboardInterruptr rÚappendÚstrrÚsysÚexc_inforrrr)rÚ test_caseÚisTestZ old_successÚer"rrrÚtestPartExecutor7s* $  z_Outcome.testPartExecutor)N)F)r r r rÚ contextlibÚcontextmanagerr&rrrrr-s rcCs|S©Nr)ÚobjrrrÚ_idUsr+cOst |||f¡dS)znSame as addCleanup, except the cleanup items are called even if setUpModule fails (unlike tearDownModule).N)Ú_module_cleanupsr)ÚfunctionÚargsÚkwargsrrrÚaddModuleCleanupZsr0c Csdg}trTt ¡\}}}z|||ŽWqtk rP}z| |¡W5d}~XYqXq|r`|d‚dS)zWExecute all module cleanup functions. Normally called for you after tearDownModule.Nr)r,ÚpopÚ Exceptionr)Ú exceptionsr-r.r/ÚexcrrrÚdoModuleCleanups`sr5cs,‡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_wrappervsz-skip..decorator..skip_wrapperT)Ú isinstanceÚtypeÚ functoolsÚwrapsÚ__unittest_skip__Ú__unittest_skip_why__)Ú test_itemr:r8rrÚ decoratorts zskip..decoratorÚ)r;ÚtypesÚ FunctionType)r9rBrArr8rÚskipps  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Ú šsz_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Ú standardMsgrWrrrÚ _raiseFailure¢sz"_BaseTestCaseContext._raiseFailureN)r r r rrZrrrrrU�srUc@seZdZddd„Zdd„ZdS)Ú_AssertRaisesBaseContextNcCs@t ||¡||_||_|dk r*t |¡}||_d|_d|_dSr)) rUrrTr#ÚreÚcompileÚexpected_regexÚobj_namerW)rrTr#r^rrrr¨s  z!_AssertRaisesBaseContext.__init__c Cs²z¦t|j|jƒs"td||jfƒ‚|sV| dd¡|_|rNtdtt|ƒƒfƒ‚|W¢TS|^}}z |j |_ Wnt k rˆt |ƒ|_ YnX|�|||ŽW5QRXW5d}XdS)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. Nz%s() arg 1 must be %srWz3%r is an invalid keyword argument for this function) rLrTÚ _base_typeÚ TypeErrorÚ_base_type_strr1rWÚnextÚiterr r_ÚAttributeErrorr )rÚnamer.r/Z callable_objrrrÚhandle²s(ÿ ÿ z_AssertRaisesBaseContext.handle)N)r r r rrgrrrrr[¦s r[c@s(eZdZdZeZdZdd„Zdd„ZdS)Ú_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Æ|dkrbz |jj}Wntk r2t|jƒ}YnX|jrP| d ||j¡¡ql| d |¡¡n t |¡t ||jƒs|dS|  d¡|_ |j dkr–dS|j }|  t|ƒ¡sÂ| d |jt|ƒ¡¡dS)Nz{} not raised by {}z {} not raisedFTú"{}" does not match "{}")rTr rer r_rZÚformatÚ tracebackÚ clear_framesrSÚwith_tracebackZ exceptionr^ÚsearchÚpattern)rÚexc_typeÚ exc_valueÚtbÚexc_namer^rrrÚ__exit__Ùs.  ÿ    ÿz_AssertRaisesContext.__exit__N) r r r rÚ BaseExceptionr`rbrjrvrrrrrhÐs rhc@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ÚgetattrryÚwarningsÚcatch_warningsÚwarnings_managerrjÚ simplefilterrT)rÚvrrrrjûs  z_AssertWarnsContext.__enter__cCs|j |||¡|dk rdSz |jj}Wntk rFt|jƒ}YnXd}|jD]Z}|j}t||jƒsjqR|dkrv|}|j dk r’|j   t|ƒ¡s’qR||_ |j |_ |j |_ dS|dk rÐ| d |j jt|ƒ¡¡|jrì| d ||j¡¡n| d |¡¡dS)Nrkz{} not triggered by {}z{} not triggered)r‚rvrTr rer r€Úmessager;r^rpZwarningÚfilenameÚlinenorZrlrqr_)rrrrsrtruZfirst_matchingÚmÚwrrrrvs@    ÿÿ ÿz_AssertWarnsContext.__exit__N) r r r rÚWarningr`rbrjrvrrrrrxõs  rxÚ_LoggingWatcherÚrecordsÚoutputc@s(eZdZdZdd„Zdd„Zdd„ZdS) Ú_CapturingHandlerzM A logging handler capturing all (raw and formatted) logging output. cCstj |¡tggƒ|_dSr))ÚloggingÚHandlerrr‹Úwatcherrirrrr3s z_CapturingHandler.__init__cCsdSr)rrirrrÚflush7sz_CapturingHandler.flushcCs*|jj |¡| |¡}|jj |¡dSr))r‘rŒrrlr�)rrzrWrrrÚemit:s z_CapturingHandler.emitN)r r r rrr’r“rrrrrŽ.srŽc@s,eZdZdZdZdd„Zdd„Zdd„Zd S) Ú_AssertLogsContextz:A context manager used to implement TestCase.assertLogs().z"%(levelname)s:%(name)s:%(message)scCs:t ||¡||_|r(tj ||¡|_ntj|_d|_dSr)) rUrÚ logger_namer�Z _nameToLevelÚgetÚlevelÚINFOrW)rr#r•r—rrrrFs  z_AssertLogsContext.__init__cCs’t|jtjƒr|j}|_nt |j¡}|_t |j¡}tƒ}|  |¡|j |_ |j dd…|_ |j |_|j|_|g|_ | |j ¡d|_|j S)NF)r;r•r�ZLoggerÚloggerZ getLoggerZ FormatterÚLOGGING_FORMATrŽZ setFormatterr‘ÚhandlersÚ old_handlersr—Ú old_levelÚ propagateÚ old_propagateÚsetLevel)rr™Z formatterZhandlerrrrrjOs   z_AssertLogsContext.__enter__cCs`|j|j_|j|j_|j |j¡|dk r.dSt|jj ƒdkr\|  d  t   |j¡|jj¡¡dS)NFrz-no logs of level {} or higher triggered on {})rœr™r›rŸržr r�Úlenr‘rŒrZrlr�Z getLevelNamer—rf)rrrrsrtrrrrv`s   ÿÿz_AssertLogsContext.__exit__N)r r r rršrrjrvrrrrr”As  r”c@seZdZdd„ZdS)Ú_OrderedChainMapccs8tƒ}|jD]&}|D]}||kr| |¡|Vqq dSr))ÚsetÚmapsÚadd)rÚseenÚmappingÚkrrrÚ__iter__ns   z_OrderedChainMap.__iter__N)r r r r©rrrrr¢msr¢c@seZdZdZeZdZdZdZdZ gZ d•dd„Z d d „Z d d „Z d e _edd„ƒZdd„Zdd„Zedd„ƒZedd„ƒZdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zeje fd*d+„ƒZ!d,d-„Z"d.d/„Z#d0d1„Z$d2d3„Z%d4d5„Z&d6d7„Z'd8d9„Z(d–d;d<„Z)d=d>„Z*ed?d@„ƒZ+dAdB„Z,dCdD„Z-dEdF„Z.d—dGdH„Z/d˜dIdJ„Z0d™dKdL„Z1dMdN„Z2dOdP„Z3dQdR„Z4dšdSdT„Z5dUdV„Z6d›dWdX„Z7dœdYdZ„Z8d�d[d\„Z9džd]d^„Z:dŸd_d`„Z;d dadb„Zd¢dgdh„Z?d£didj„Z@d¤dkdl„ZAd¥dmdn„ZBd¦dodp„ZCd§dqdr„ZDd¨dsdt„ZEd©dudv„ZFdªdwdx„ZGd«dydz„ZHd¬d{d|„ZId­d}d~„ZJd®dd€„ZKd¯d�d‚„ZLd°dƒd„„ZMd±d…d†„ZNd²d‡dˆ„ZOd³d‰dŠ„ZPd‹dŒ„ZQd�dŽ„ZRd´d�d�„ZSdµd‘d’„ZTd“d”„ZUeUe8ƒZVZWeUe9ƒZXZYeUe:ƒZZZ[eUe;ƒZ\Z]eUe1ƒZ^Z_eUe3ƒZ`eUe0ƒZaeUeQƒZbeUeSƒZceUeTƒZdd:S)¶Ú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.tk rN|dkrJtd|j|fƒ‚Yn X|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Ú_testMethodDocrreÚ ValueErrorÚ __class__rÚ _cleanupsÚ_subtestÚ_type_equality_funcsÚaddTypeEqualityFuncÚdictr|rQr£Ú frozensetr )rZ methodNameÚ testMethodrrrr¨s(ÿ      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Œt|ƒdkr|^}}}nV|s&tdƒ‚nHd|krZ| d¡}|^}}ddl}|jdtdd�ntdt|ƒd ƒ‚t|ƒ}|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).éz>descriptor 'addCleanup' of 'TestCase' object needs an argumentr-rNz4Passing 'function' as keyword argument is deprecated)Ú stacklevelz:addCleanup expected at least 1 positional argument, got %dr) r¡rar1r€ÚwarnÚDeprecationWarningrQr¶r)r.r/rr-r€rrrÚ addCleanup×s"    ÿ ÿzTestCase.addCleanupz%($self, function, /, *args, **kwargs)cOs|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.NrrirrrÚsetUpöszTestCase.setUpcCsdS)zAHook method for deconstructing the test fixture after testing it.NrrirrrÚ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Ú tearDownClassszTestCase.tearDownClasscCsdS)NrrrirrrÚcountTestCasesszTestCase.countTestCasescCst ¡Sr))rZ TestResultrirrrÚ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±rirrrÚidsz TestCase.idcCs t|ƒt|ƒk rtS|j|jkSr))r<ÚNotImplementedr±©rÚotherrrrÚ__eq__szTestCase.__eq__cCstt|ƒ|jfƒSr))Úhashr<r±rirrrÚ__hash__ szTestCase.__hash__cCsd|jt|jƒfS©Nz%s (%s))r±rrµrirrrÚ__str__#szTestCase.__str__cCsdt|jƒ|jfS)Nz<%s testMethod=%s>rÒrirrrÚ__repr__&sÿzTestCase.__repr__cCs<t|ddƒ}|dk r |||ƒnt dtd¡| |¡dS)NÚaddSkipz4TestResult has no addSkip method, skips not reportedr½)rr€r¿ÚRuntimeWarningÚ addSuccess)rrr#r9rÝrrrÚ_addSkip*s  ÿzTestCase._addSkipc ks´|jdks|jjsdVdS|j}|dkr4t|ƒ}n |j |¡}t|||ƒ|_zX|jj|jdd�� dVW5QRX|jjs˜|jj }|dk r¤|j r¤t ‚n |jj r¤t ‚W5||_XdS)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)rrWrâÚparentZ params_maprrrrÚsubTest3s$  zTestCase.subTestcCs`|D]V\}}t|tƒr(| |j||¡q|dk rt|d|jƒrN| ||¡q| ||¡qdS)Nr)r;rärr#rSrXÚ addFailureZaddError)rrrÚtestr"rrrÚ_feedErrorsToResultRs  zTestCase._feedErrorsToResultcCsDz |j}Wn*tk r4t dt¡| |¡Yn X|||ƒdS)Nz@TestResult has no addExpectedFailure method, reporting as passes)ÚaddExpectedFailurerer€r¿rÞrß)rrr"rêrrrÚ_addExpectedFailure\s ÿzTestCase._addExpectedFailurec Cshz |j}WnPtk rZt dt¡z td‚Wn$tk rT| |t ¡¡YnXYn X||ƒdS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure) ÚaddUnexpectedSuccessrer€r¿rÞrrçr!r")rrrìrrrÚ_addUnexpectedSuccessfs ÿ zTestCase._addUnexpectedSuccesscCs | ¡dSr))rÅrirrrÚ _callSetUpuszTestCase._callSetUpcCs |ƒdSr)r)rÚmethodrrrÚ_callTestMethodxszTestCase._callTestMethodcCs | ¡dSr))rÆrirrrÚ _callTearDown{szTestCase._callTearDowncOs|||ŽdSr)r©rr-r.r/rrrÚ _callCleanup~szTestCase._callCleanupNc Cs|}|dkr.| ¡}t|ddƒ}|dk r.|ƒ| |¡t||jƒ}t|jddƒs^t|ddƒrœz,t|jddƒpxt|ddƒ}| |||¡W5| |¡XdSt|ddƒ}t|ddƒ}|pº|}t|ƒ} zô| |_ |   |¡�|  ¡W5QRX| j�r@|| _| j |dd ��| |¡W5QRXd| _|   |¡�| ¡W5QRX| ¡| jD]\} } | || | ¡�qN| || j¡| j�r²|�r¨| j �rœ| || j ¡n | |¡n | |¡|W¢S| |¡|dk�rêt|ddƒ} | dk �rê| ƒ| j  ¡d| _ d|_ XdS) NÚ startTestRunr?Fr@rCrKÚ stopTestRunTrá)rËrZ startTestr±rµZstopTestràrrÚclearrr²r&rîrrrðrñÚ doCleanupsrrérërírß) rrZ orig_resultrôr¼Zskip_whyZexpecting_failure_methodZexpecting_failure_classrÚoutcomerõrèr9rrrÚrun�st    ÿ ÿ ÿÿ         z TestCase.runc CsR|jp tƒ}|jrL|j ¡\}}}| |¡�|j|f|ž|ŽW5QRXq |jS)zNExecute all cleanup functions. Normally called for you after tearDown.)r²rr¶r1r&rór)rrør-r.r/rrrr÷Æs   zTestCase.doCleanupsc Csdg|_|jr`|j ¡\}}}z|||ŽWqtk r\}z|j t ¡¡W5d}~XYqXqdS)zYExecute all class cleanup functions. Normally called for you after tearDownClass.N)ZtearDown_exceptionsrÂr1r2rr!r")rÃr-r.r/r4rrrÚdoClassCleanupsÓszTestCase.doClassCleanupscOs |j||ŽSr))rù)rr.ÚkwdsrrrÚ__call__ßszTestCase.__call__cCsF| ¡t||jƒƒ| ¡|jrB|j d¡\}}}|||ŽqdS)z6Run the test without collecting errors in a TestResultéÿÿÿÿN)rÅrr±rÆr¶r1ròrrrÚdebugâs zTestCase.debugcCs t|ƒ‚dS)zSkip this test.Nr6)rr9rrrÚskipTestëszTestCase.skipTestcCs| |¡‚dS)z)Fail immediately, with the given message.N)rX)rrWrrrÚfailïsz TestCase.failcCs&|r"| |dt|ƒ¡}| |¡‚dS)z#Check that the expression is false.z%s is not falseN©rVrrX©rÚexprrWrrrÚ assertFalseószTestCase.assertFalsecCs&|s"| |dt|ƒ¡}| |¡‚dS)z"Check that the expression is true.z%s is not trueNrrrrrÚ assertTrueùszTestCase.assertTruecCsV|js|p |S|dkr|Szd||fWStk rPdt|ƒt|ƒfYSXdS)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)rrWrYrrrrVÿs zTestCase._formatMessagecOs(t||ƒ}z| d||¡W¢Sd}XdS)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) NÚ assertRaises©rhrg)rÚexpected_exceptionr.r/Úcontextrrrrs 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©rxrg)rÚexpected_warningr.r/r rrrr 5s zTestCase.assertWarnscCs t|||ƒ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”)rr™r—rrrÚ assertLogsTszTestCase.assertLogscCsFt|ƒt|ƒkr@|j t|ƒ¡}|dk r@t|tƒr}z| d|¡W5d}~XYn0tk rl}z| d|¡W5d}~XYnXz| |¡}Wn^tk r¬}z| d|¡W5d}~XYn0tk rÚ}z| d|¡W5d}~XYnX|sè|sèdSg}|�r| d¡|D]}| t|ƒ¡�q|�r@| d¡|D]}| t|ƒ¡�q*d |¡} | | || ¡¡dS)a¯A set-specific equality assertion. Args: set1: The first set to compare. set2: The second set to compare. msg: Optional message to use on failure instead of a list of differences. assertSetEqual uses ducktyping to support different types of sets, and is optimized for sets specifically (parameters must support a difference method). z/invalid type when attempting set difference: %sNz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:rÌ)Ú differencerarrerÚreprr%rV) rZset1Zset2rWZ difference1r%Z difference2ÚlinesÚitemrYrrrr¯ks2      zTestCase.assertSetEqualcCs2||kr.dt|ƒt|ƒf}| | ||¡¡dS)zDJust like self.assertTrue(a in b), but with a nicer default message.z%s not found in %sN©rrrV©rÚmemberZ containerrWrYrrrÚassertIn–s ÿzTestCase.assertIncCs2||kr.dt|ƒt|ƒf}| | ||¡¡dS)zHJust like self.assertTrue(a not in b), but with a nicer default message.z%s unexpectedly found in %sNr7r8rrrÚ assertNotIn�s ÿzTestCase.assertNotIncCs2||k r.dt|ƒt|ƒf}| | ||¡¡dS)zDJust like self.assertTrue(a is b), but with a nicer default message.z %s is not %sNr7©rZexpr1Zexpr2rWrYrrrÚassertIs¤s ÿzTestCase.assertIscCs,||kr(dt|ƒf}| | ||¡¡dS)zHJust like self.assertTrue(a is not b), but with a nicer default message.zunexpectedly identical: %sNr7r<rrrÚ assertIsNot«szTestCase.assertIsNotc Cs~| |td¡| |td¡||krzdt||ƒ}dd t t |¡ ¡t |¡ ¡¡¡}|  ||¡}|  |  ||¡¡dS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryrrÌ) ÚassertIsInstancerºrr%r&r'r(r)r*r+rrV)rZd1Zd2rWrYrrrrr¬±s   þ zTestCase.assertDictEqualc CsÎt dt¡g}g}| ¡D]L\}}||kr8| |¡q|||kr| dt|ƒt|ƒt||ƒf¡q|sv|svdSd}|r–dd dd„|Dƒ¡}|r¸|r¦|d 7}|d d |¡7}| | ||¡¡dS) z2Checks whether dictionary is a superset of subset.z&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %sNrCz Missing: %sú,css|]}t|ƒVqdSr))r)rMrˆrrrrPÐsz4TestCase.assertDictContainsSubset..z; zMismatched values: %s) r€r¿rÀÚitemsrrr%rrV) rZsubsetZ dictionaryrWZmissingZ mismatchedÚkeyÚvaluerYrrrÚassertDictContainsSubset½s4ÿ    ÿÿ ÿ z!TestCase.assertDictContainsSubsetc Cs¦t|ƒt|ƒ}}zt |¡}t |¡}Wntk rHt||ƒ}YnX||krVdSt||ƒ}|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Ú ôsz-TestCase.assertCountEqual..rÌ) r|Ú collectionsÚCounterrarrr%r+rVr) rrrrWZ first_seqZ second_seqZ differencesrYr5r.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)r?r r¡Ú_diffThresholdrr*rÍrr%r&r'r+rrV)rrrrWZ firstlinesZ secondlinesrYrrrrr°ú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 %sNr7©rÚaÚbrWrYrrrÚ 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 %sNr7rKrrrÚassertLessEqualszTestCase.assertLessEqualcCs2||ks.dt|ƒt|ƒf}| | ||¡¡dS)zCJust like self.assertTrue(a > b), but with a nicer default message.z%s not greater than %sNr7rKrrrÚ 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 %sNr7rKrrrÚassertGreaterEqual szTestCase.assertGreaterEqualcCs,|dk r(dt|ƒf}| | ||¡¡dS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz%s is not Noner7©rr*rWrYrrrÚ assertIsNone&szTestCase.assertIsNonecCs"|dkrd}| | ||¡¡dS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)rrVrRrrrÚ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;rrrV©rr*rÃrWrYrrrr?2s zTestCase.assertIsInstancecCs0t||ƒr,dt|ƒ|f}| | ||¡¡dS)z,Included for symmetry with assertIsInstance.z%s is an instance of %rNrUrVrrrÚassertNotIsInstance9s 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 rrrrX?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 )rrr^r.r/r rrrrYOs 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]rprqrVrX)rÚtextr^rWrYrrrÚ assertRegexbs  ÿ 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 rZr\r]rpÚstartÚendrqrVrX)rr[Zunexpected_regexrWÚmatchrYrrrÚassertNotRegexns  ý zTestCase.assertNotRegexcs‡fdd„}|S)Ncs t d ˆj¡td¡ˆ||ŽS)NzPlease use {0} instead.r½)r€r¿rlr rÀr7©Ú original_funcrrÚdeprecated_func~s  þz,TestCase._deprecate..deprecated_funcr)rbrcrrarÚ _deprecate}s 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)er r r rÚAssertionErrorrXrr0rJZ_classSetupFailedrÂrr¹rÁÚ__text_signature__Ú classmethodrÄ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ÿrrrrVrr rrrrrrrr/r+r­r®r¯r:r;r=r>r¬rDrHr°rNrOrPrQrSrTr?rWrXrYr\r`rdZfailUnlessEqualZ assertEqualsZ failIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrrªws          E      !    ÿ -ÿ # 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))ÚsuperrirÚ _setUpFuncÚ _tearDownFuncÚ _testFuncÚ _description)rZtestFuncrÅrÆZ description©rµrrrœs zFunctionTestCase.__init__cCs|jdk r| ¡dSr))rkrirrrrÅ£s zFunctionTestCase.setUpcCs|jdk r| ¡dSr))rlrirrrrƧs zFunctionTestCase.tearDowncCs | ¡dSr))rmrirrrr««szFunctionTestCase.runTestcCs|jjSr))rmr rirrrrÓ®szFunctionTestCase.idcCs@t||jƒstS|j|jko>|j|jko>|j|jko>|j|jkSr))r;rµrÔrkrlrmrnrÕrrrr×±s   ÿ þ ýzFunctionTestCase.__eq__cCstt|ƒ|j|j|j|jfƒSr))rØr<rkrlrmrnrirrrrÙºsÿzFunctionTestCase.__hash__cCsdt|jƒ|jjfSrÚ)rrµrmr rirrrrÛ¾s ÿzFunctionTestCase.__str__cCsdt|jƒ|jfS)Nz <%s tec=%s>)rrµrmrirrrrÜÂs ÿzFunctionTestCase.__repr__cCs2|jdk r|jS|jj}|r.| d¡d ¡p0dS)NrÌr)rnrmrrÎrÍrÏrrrrÑÆs z!FunctionTestCase.shortDescription)NNN)r r r rrrÅrÆr«rÓr×rÙrÛrÜrÑÚ __classcell__rrrorri“s ricsDeZdZ‡fdd„Zdd„Zdd„Zdd„Zd d „Zd d „Z‡Z S) räcs(tƒ ¡||_||_||_|j|_dSr))rjrÚ_messager#rârX)rr#r…rârorrrÏs  z_SubTest.__init__cCs tdƒ‚dS)Nzsubtests cannot be run directly)r rirrrr«Ösz_SubTest.runTestcCs^g}|jtk r | d |j¡¡|jrPd dd„|j ¡Dƒ¡}| d |¡¡d |¡p\dS)Nz[{}]z, css|]\}}d ||¡VqdS)z{}={!r}N)rl)rMr¨r„rrrrPÞsÿz+_SubTest._subDescription..z({})ú z ())rqrhrrlrâr%rA)rÚpartsZ params_descrrrÚ_subDescriptionÙs  þz_SubTest._subDescriptioncCsd |j ¡| ¡¡S©Nz{} {})rlr#rÓrtrirrrrÓäsz _SubTest.idcCs |j ¡S)zlReturns a one-line description of the subtest, or None if no description has been provided. )r#rÑrirrrrÑçsz_SubTest.shortDescriptioncCsd |j| ¡¡Sru)rlr#rtrirrrrÛísz_SubTest.__str__) r r r rr«rtrÓrÑrÛrprrrorräÍs   rä)4rr!r=r&r�r(r\r€rFr'rmrDrCrÚutilrrrrrZ __unittestÚobjectrhr1r2r rrrr+r,r0r5rFrIrJrrLrUr[rhrxÚ namedtupler‹r�rŽr”ÚChainMapr¢rªrirärrrrÚsd ( *%5ÿ, $: