o ?OgF!@s\dZddlZddlZddlZddlmZddlmZdZddZ d Z d Z Gd d d e Z dS) zTest result objectN)utilwrapsTcstfdd}|S)Ncs*t|ddr ||g|Ri|S)NfailfastF)getattrstop)selfargskwmethod6/opt/alt/python310/lib64/python3.10/unittest/result.pyinner s zfailfast..innerr)r rrr rr srz Stdout: %sz Stderr: %sc@seZdZdZdZdZdZd0ddZddZdd Z d d Z d d Z ddZ ddZ ddZeddZeddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/ZdS)1 TestResultaHolder 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)rfailureserrorstestsRunskippedexpectedFailuresunexpectedSuccesses shouldStopbuffer tb_locals_stdout_buffer_stderr_buffersysstdout_original_stdoutstderr_original_stderr _mirrorOutput)r streamZ descriptions verbosityrrr__init__&s zTestResult.__init__cCdS)z#Called by TestRunner after test runNrr rrr printErrors7zTestResult.printErrorscCs |jd7_d|_|dS)z-Called when the given test is about to be runrFN)rr" _setupStdoutr testrrr startTest:s zTestResult.startTestcCs<|jr|jdurt|_t|_|jt_|jt_dSdS)N)rrioStringIOrrrr 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+rrrstopTestNs zTestResult.stopTestcCs|jrV|jr6tj}tj}|r#|ds|d7}|jt ||r6|ds.|d7}|j t ||jt_|j t_|j d|j |j d|jdSdS)N r)rr"rrgetvaluer endswithrwrite STDOUT_LINEr! STDERR_LINErseektruncater)r outputerrorrrrr1Ss&       zTestResult._restoreStdoutcCr&)zmCalled once after all tests are executed. See stopTest for a method called after each test. Nrr'rrr stopTestRunhr)zTestResult.stopTestRuncC"|j||||fd|_dS)zmCalled when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info(). TN)rappend_exc_info_to_stringr"r r,errrrraddErrorns 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|ddr|t|d|jr|j}n|j}|||||fd|_dSdS)zCalled 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 issubclassfailureExceptionrrr?r@r")r r,ZsubtestrBrrrr addSubTest}s  zTestResult.addSubTestcCr&)z-Called when a test has completed successfullyNrr+rrr addSuccessszTestResult.addSuccesscCs|j||fdS)zCalled when a test is skipped.N)rr?)r r,reasonrrraddSkipszTestResult.addSkipcCs|j||||fdS)z/Called when an expected failure/error occurred.N)rr?r@rArrraddExpectedFailureszTestResult.addExpectedFailurecCs|j|dS)z5Called when a test was expected to fail, but succeed.N)rr?r+rrraddUnexpectedSuccessszTestResult.addUnexpectedSuccesscCs>t|jt|jkodknot|d pt|jdkS)z/Tells whether or not this result was a success.rr)lenrrhasattrrr'rrr wasSuccessfuls$  zTestResult.wasSuccessfulcCs d|_dS)z+Indicates that the tests should be aborted.TN)rr'rrrrs zTestResult.stopc Cs|\}}}|||||}tj||||jdd}t|}|jrOtj }tj } |r=| ds6|d7}| t || rO| dsH| d7} | t| d|S)z>Converts a sys.exc_info()-style tuple of values into a string.T)capture_localscompactr3)_clean_tracebacks tracebackTracebackExceptionrlistformatrrrr4r r5r?r7r8join) r rBr,exctypevaluetbZtb_eZmsgLinesr;r<rrrr@s&       zTestResult._exc_info_to_stringc Csd}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) idpop_is_relevant_tb_leveltb_nextrF_remove_unittest_tb_frames __traceback__ __cause__ __context__r?typeadd) r rYrZr[r,ZretfirstZexcsseencrrrrSs.    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|jt|jfS)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 functoolsrrirr7r8objectrrrrrs