ñÕYfã@s‚dZddlZddlZddlZddlmZddlmZdZdd„Z d Z d Z Gd d „d e ƒZ dS) zTest result objectéNé)Úutil)ÚwrapsTcs"tˆƒ‡fdd†ƒ}|S)Ncs,t|ddƒr|jƒˆ|||ŽS)NÚfailfastF)ÚgetattrÚstop)ÚselfÚargsÚkw)Úmethod©ú4/opt/alt/python35/lib64/python3.5/unittest/result.pyÚinner s zfailfast..inner)r)r rr )r r r srz Stdout: %sz Stderr: %sc@s?eZdZdZdZdZdZddddd„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-„ZdS).Ú 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. NFcCs‘d|_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Ú verbosityr r r Ú__init__&s              zTestResult.__init__cCsdS)z#Called by TestRunner after test runNr )rr r r Ú printErrors7szTestResult.printErrorscCs&|jd7_d|_|jƒdS)z-Called when the given test is about to be runrFN)rr Ú _setupStdout)rÚtestr r r Ú startTest:s zTestResult.startTestcCsR|jrN|jdkr6tjƒ|_tjƒ|_|jt_|jt_dS)N)rrÚioÚStringIOrrrr)rr r r r%@s   zTestResult._setupStdoutcCsdS)zpCalled once before any tests are executed. See startTest for a method called before each test. Nr )rr r r Ú startTestRunHszTestResult.startTestRuncCs|jƒd|_dS)z'Called when the given test has been runFN)Ú_restoreStdoutr )rr&r r r ÚstopTestNs zTestResult.stopTestcCsì|jrè|jr–tjjƒ}tjjƒ}|rc|jdƒsO|d7}|jjt |ƒ|r–|jdƒs‚|d7}|j jt |ƒ|jt_|j t_|j j dƒ|j jƒ|jj dƒ|jjƒdS)NÚ r)rr rrÚgetvaluerÚendswithrÚwriteÚ STDOUT_LINErÚ STDERR_LINErÚseekÚtruncater)rÚoutputÚerrorr r r r+Ss$       zTestResult._restoreStdoutcCsdS)zmCalled once after all tests are executed. See stopTest for a method called after each test. Nr )rr r r Ú stopTestRunhszTestResult.stopTestRuncCs/|jj||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 )rr&Úerrr r r ÚaddErrorns"zTestResult.addErrorcCs/|jj||j||ƒfƒd|_dS)zdCalled when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info().TN)rr8r9r )rr&r:r r r Ú addFailurevs"zTestResult.addFailurecCs|dk r{t|ddƒr(|jƒt|d|jƒrJ|j}n |j}|j||j||ƒfƒd|_dS)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ÚfailureExceptionrrr8r9r )rr&Zsubtestr:rr r r Ú addSubTest}s    zTestResult.addSubTestcCsdS)z-Called when a test has completed successfullyNr )rr&r r r Ú addSuccessŽszTestResult.addSuccesscCs|jj||fƒdS)zCalled when a test is skipped.N)rr8)rr&Úreasonr r r ÚaddSkip’szTestResult.addSkipcCs&|jj||j||ƒfƒdS)z/Called when an expected failure/error occurred.N)rr8r9)rr&r:r r r ÚaddExpectedFailure–s zTestResult.addExpectedFailurecCs|jj|ƒdS)z5Called when a test was expected to fail, but succeed.N)rr8)rr&r r r ÚaddUnexpectedSuccess›szTestResult.addUnexpectedSuccesscCsQt|jƒt|jƒko)dknoPt|dƒ pPt|jƒdkS)z/Tells whether or not this result was a success.rr)ÚlenrrÚhasattrr)rr r r Ú wasSuccessful s.zTestResult.wasSuccessfulcCs d|_dS)z+Indicates that the tests should be aborted.TN)r)rr r r r©szTestResult.stopc Cs%|\}}}x"|r3|j|ƒr3|j}qW||jkrU|j|ƒ}nd}tj|||d|d|jƒ}t|jƒƒ}|j rt j j ƒ} t j j ƒ} | rè| jdƒs×| d7} |jt| ƒ| r| jdƒs| d7} |jt| ƒdj|ƒS)z>Converts a sys.exc_info()-style tuple of values into a string.NÚlimitÚcapture_localsr-Ú)Ú_is_relevant_tb_levelÚtb_nextr>Ú_count_relevant_tb_levelsÚ tracebackÚTracebackExceptionrÚlistÚformatrrrr.rr/r8r1r2Újoin) rr:r&ÚexctypeÚvalueÚtbÚlengthZtb_eZmsgLinesr5r6r r r r9­s*    zTestResult._exc_info_to_stringcCsd|jjkS)NÚ __unittest)Útb_frameÚ f_globals)rrUr r r rKËsz TestResult._is_relevant_tb_levelcCs:d}x-|r5|j|ƒ r5|d7}|j}q W|S)Nrr)rKrL)rrUrVr r r rMÎs   z$TestResult._count_relevant_tb_levelscCs5dtj|jƒ|jt|jƒt|jƒfS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclassÚ __class__rrErr)rr r r Ú__repr__Õs!zTestResult.__repr__)Ú__name__Ú __module__Ú __qualname__Ú__doc__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr#r$r'r%r*r,r+r7rr;r<r?r@rBrCrDrGrr9rKrMr[r r r r rs2                r)r_r(rrNrJrÚ functoolsrrWrr1r2Úobjectrr r r r Ús