U e5dã@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| ¡ˆ|f|ž|ŽS)NÚfailfastF)ÚgetattrÚstop)ÚselfÚargsÚkw©Úmethod©ú'/usr/lib64/python3.8/unittest/result.pyÚinner s zfailfast..innerr)r rrr rr srz Stdout: %sz Stderr: %sc@sÒeZdZdZdZdZdZd.dd„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. 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__&szTestResult.__init__cCsdS)z#Called by TestRunner after test runNr©r rrrÚ printErrors7szTestResult.printErrorscCs |jd7_d|_| ¡dS)z-Called when the given test is about to be runrFN)rr"Ú _setupStdout©r ÚtestrrrÚ startTest:szTestResult.startTestcCs8|jr4|jdkr$t ¡|_t ¡|_|jt_|jt_dS)N)rrÚioÚStringIOrrrr r&rrrr(@s    zTestResult._setupStdoutcCsdS)zpCalled once before any tests are executed. See startTest for a method called before each test. Nrr&rrrÚ startTestRunHszTestResult.startTestRuncCs| ¡d|_dS)z'Called when the given test has been runFN)Ú_restoreStdoutr"r)rrrÚstopTestNszTestResult.stopTestcCs¬|jr¨|jrltj ¡}tj ¡}|rF| d¡s6|d7}|j t |¡|rl| d¡s\|d7}|j  t |¡|jt_|j t_|j   d¡|j  ¡|j  d¡|j ¡dS)NÚ r)rr"rrÚgetvaluer ÚendswithrÚwriteÚ STDOUT_LINEr!Ú STDERR_LINErÚseekÚtruncater)r ÚoutputÚerrorrrrr/Ss$       zTestResult._restoreStdoutcCsdS)zmCalled once after all tests are executed. See stopTest for a method called after each test. Nrr&rrrÚ stopTestRunhszTestResult.stopTestRuncCs"|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ÚaddErrornszTestResult.addErrorcCs"|j || ||¡f¡d|_dS)zdCalled when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info().TN)rr<r=r"r>rrrÚ addFailurevszTestResult.addFailurecCsZ|dk rVt|ddƒr| ¡t|d|jƒr4|j}n|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ÚfailureExceptionrrr<r=r")r r*Zsubtestr?rrrrÚ addSubTest}s zTestResult.addSubTestcCsdS)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=r>rrrÚ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ƒkodknoConverts a sys.exc_info()-style tuple of values into a string.N)ÚlimitÚcapture_localsr1Ú)Ú_is_relevant_tb_levelÚtb_nextrCÚ_count_relevant_tb_levelsÚ tracebackÚTracebackExceptionrÚlistÚformatrrrr2r r3r<r5r6Újoin) r r?r*ÚexctypeÚvalueÚtbÚlengthZtb_eZmsgLinesr9r:rrrr=­s4   ÿ     zTestResult._exc_info_to_stringcCs d|jjkS)NÚ __unittest)Útb_frameÚ f_globals)r rZrrrrPËsz TestResult._is_relevant_tb_levelcCs&d}|r"| |¡s"|d7}|j}q|S)Nrr)rPrQ)r rZr[rrrrRÎs z$TestResult._count_relevant_tb_levelscCs&dt |j¡|jt|jƒt|jƒfS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclassÚ __class__rrJrrr&rrrÚ__repr__Õs ÿÿzTestResult.__repr__)NNN)Ú__name__Ú __module__Ú __qualname__Ú__doc__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr%r'r+r(r.r0r/r;rr@rArDrErGrHrIrLrr=rPrRr`rrrrrs8      r)rdr,rrSrOrÚ functoolsrr\rr5r6ÚobjectrrrrrÚs