o 0¦iF!ã@s\dZddlZddlZddlZddlmZddlmZdZdd„Z d Z d Z Gd d „d e ƒZ dS) zTest result objectéNé)Úutil©ÚwrapsTcstˆƒ‡fdd„ƒ}|S)Ncs*t|ddƒr | ¡ˆ|g|¢Ri|¤ŽS)NÚfailfastF)ÚgetattrÚstop)ÚselfÚargsÚkw©Úmethod©ú6/opt/alt/python310/lib64/python3.10/unittest/result.pyÚinner s zfailfast..innerr)r rrr rr srz Stdout: %sz Stderr: %sc@sÚeZdZdZdZdZdZd0dd„Zdd„Zdd „Z d d „Z d d „Z dd„Z dd„Z dd„Zedd„ƒZedd„ƒZdd„Zdd„Zdd„Zdd„Zed d!„ƒZd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„ZdS)1Ú TestResultaÙHolder for test result information. Test results are automatically managed by the TestCase and TestSuite classes, and do not need to be explicitly manipulated by writers of tests. Each instance holds the total number of tests run, and collections of failures and errors that occurred among those test runs. The collections contain tuples of (testcase, exceptioninfo), where exceptioninfo is the formatted traceback of the error that occurred. NFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_ d|_ d|_ t j |_t j|_d|_dS)NFr)rÚfailuresÚerrorsÚtestsRunÚskippedÚexpectedFailuresÚunexpectedSuccessesÚ shouldStopÚbufferÚ tb_localsÚ_stdout_bufferÚ_stderr_bufferÚsysÚstdoutÚ_original_stdoutÚstderrÚ_original_stderrÚ _mirrorOutput)r ÚstreamZ descriptionsÚ verbosityrrrÚ__init__&s zTestResult.__init__cCódS)z#Called by TestRunner after test runNr©r rrrÚ printErrors7ózTestResult.printErrorscCs |jd7_d|_| ¡dS)z-Called when the given test is about to be runrFN)rr"Ú _setupStdout©r ÚtestrrrÚ startTest:s zTestResult.startTestcCs<|jr|jdurt ¡|_t ¡|_|jt_|jt_dSdS)N)rrÚioÚStringIOrrrr r'rrrr*@s    ûzTestResult._setupStdoutcCr&)zpCalled once before any tests are executed. See startTest for a method called before each test. Nrr'rrrÚ startTestRunHr)zTestResult.startTestRuncCs| ¡d|_dS)z'Called when the given test has been runFN)Ú_restoreStdoutr"r+rrrÚstopTestNs zTestResult.stopTestcCs°|jrV|jr6tj ¡}tj ¡}|r#| d¡s|d7}|j t |¡|r6| d¡s.|d7}|j  t |¡|jt_|j t_|j   d¡|j  ¡|j  d¡|j ¡dSdS)NÚ r)rr"rrÚgetvaluer ÚendswithrÚwriteÚ STDOUT_LINEr!Ú STDERR_LINErÚseekÚtruncater)r ÚoutputÚerrorrrrr1Ss&       îzTestResult._restoreStdoutcCr&)zmCalled once after all tests are executed. See stopTest for a method called after each test. Nrr'rrrÚ stopTestRunhr)zTestResult.stopTestRuncCó"|j || ||¡f¡d|_dS)zmCalled when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info(). TN)rÚappendÚ_exc_info_to_stringr"©r r,ÚerrrrrÚaddErrorns zTestResult.addErrorcCr>)zdCalled when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info().TN)rr?r@r"rArrrÚ addFailurevs zTestResult.addFailurecCs^|dur-t|ddƒr| ¡t|d|jƒr|j}n|j}| || ||¡f¡d|_dSdS)z©Called at the end of a subtest. 'err' is None if the subtest ended successfully, otherwise it's a tuple of values as returned by sys.exc_info(). NrFrT) rrÚ issubclassÚfailureExceptionrrr?r@r")r r,ZsubtestrBrrrrÚ addSubTest}s  øzTestResult.addSubTestcCr&)z-Called when a test has completed successfullyNrr+rrrÚ addSuccessŽszTestResult.addSuccesscCs|j ||f¡dS)zCalled when a test is skipped.N)rr?)r r,ÚreasonrrrÚaddSkip’szTestResult.addSkipcCs|j || ||¡f¡dS)z/Called when an expected failure/error occurred.N)rr?r@rArrrÚaddExpectedFailure–sÿzTestResult.addExpectedFailurecCs|j |¡dS)z5Called when a test was expected to fail, but succeed.N)rr?r+rrrÚaddUnexpectedSuccess›szTestResult.addUnexpectedSuccesscCs>t|jƒt|jƒkodknot|dƒ pt|jƒdkS)z/Tells whether or not this result was a success.rr)ÚlenrrÚhasattrrr'rrrÚ wasSuccessful s$  þzTestResult.wasSuccessfulcCs d|_dS)z+Indicates that the tests should be aborted.TN)rr'rrrr©s zTestResult.stopc Cs¨|\}}}| ||||¡}tj||||jdd�}t| ¡ƒ}|jrOtj  ¡}tj   ¡} |r=|  d¡s6|d7}|  t |¡| rO|   d¡sH| d7} |  t| ¡d |¡S)z>Converts a sys.exc_info()-style tuple of values into a string.T)Úcapture_localsÚcompactr3Ú)Ú_clean_tracebacksÚ tracebackÚTracebackExceptionrÚlistÚformatrrrr4r r5r?r7r8Újoin) r rBr,ÚexctypeÚvalueÚtbZtb_eZmsgLinesr;r<rrrr@­s& þ      zTestResult._exc_info_to_stringc CsÔd}d}|||fg}t|ƒh}|rh| ¡\}}}|r)| |¡r)|j}|r)| |¡s||jur3| |¡|r:|}d}n||_|durf|j|jfD]} | duret| ƒ|vre|  t | ƒ| | jf¡|  t| ƒ¡qG|s|S)NTF) ÚidÚpopÚ_is_relevant_tb_levelÚtb_nextrFÚ_remove_unittest_tb_framesÚ __traceback__Ú __cause__Ú __context__r?ÚtypeÚadd) r rYrZr[r,ZretÚfirstZexcsÚseenÚcrrrrSÃs.  ÿ  €ìzTestResult._clean_tracebackscCs d|jjvS)NÚ __unittest)Útb_frameÚ f_globals)r r[rrrr^ßs z TestResult._is_relevant_tb_levelcCs@d}|r| |¡s|}|j}|r| |¡r |durd|_dSdS)aTruncates usercode tb at the first unittest frame. If the first frame of the traceback is in user code, the prefix up to the first unittest frame is returned. If the first frame is already in the unittest module, the traceback is not modified. N)r^r_)r r[Úprevrrrr`âsþ ÿz%TestResult._remove_unittest_tb_framescCs&dt |j¡|jt|jƒt|jƒfS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclassÚ __class__rrMrrr'rrrÚ__repr__ñs ÿÿzTestResult.__repr__)NNN)Ú__name__Ú __module__Ú __qualname__Ú__doc__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr%r(r-r*r0r2r1r=rrCrDrGrHrJrKrLrOrr@rSr^r`rnrrrrrs<       r)rrr.rrTrRrÚ functoolsrrirr7r8ÚobjectrrrrrÚs