
    F\h#                     `    S r SSKrSSKrSSKrSSKJr  SSKJr  SrS r	Sr
S	r " S
 S\5      rg)zTest result object    N   )utilwrapsTc                 0   ^  [        T 5      U 4S j5       nU$ )Nc                 `   > [        U SS5      (       a  U R                  5         T" U /UQ70 UD6$ )NfailfastF)getattrstop)selfargskwmethods      &/usr/lib/python3.13/unittest/result.pyinnerfailfast.<locals>.inner   s0    4U++IIKd(T(R((    r   )r   r   s   ` r   r	   r	      s     
6]) ) Lr   z
Stdout:
%sz
Stderr:
%sc                       \ rS rSrSrSrSrSrSS jrS r	S r
S rS	 rS
 rS rS r\S 5       r\S 5       rS rS rS rS r\S 5       rS rS rS rS rS rS rS rS rSr g)
TestResult   a  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.
NFc                    SU l         / U l        / U l        SU l        / U l        / U l        / U l        / U l        SU l        SU l	        SU l
        S U l        S U l        [        R                  U l        [        R                   U l        SU l        g )NFr   )r	   failureserrorstestsRunskippedexpectedFailuresunexpectedSuccessescollectedDurations
shouldStopbuffer	tb_locals_stdout_buffer_stderr_buffersysstdout_original_stdoutstderr_original_stderr_mirrorOutput)r   streamdescriptions	verbositys       r   __init__TestResult.__init__&   s     "#% "$"" #

 #

"r   c                     g)z#Called by TestRunner after test runN r   s    r   printErrorsTestResult.printErrors8       r   c                 \    U =R                   S-  sl         SU l        U R                  5         g)z-Called when the given test is about to be runr   FN)r   r)   _setupStdoutr   tests     r   	startTestTestResult.startTest;   s$    "r   c                     U R                   (       al  U R                  c4  [        R                  " 5       U l        [        R                  " 5       U l        U R                  [
        l        U R                  [
        l        g g )N)r    r#   ioStringIOr"   r$   r%   r'   r1   s    r   r6   TestResult._setupStdoutA   sP    ;;""*&(kkm#&(kkm#,,CJ,,CJ r   c                     g)z`Called once before any tests are executed.

See startTest for a method called before each test.
Nr0   r1   s    r   startTestRunTestResult.startTestRunI   r4   r   c                 2    U R                  5         SU l        g)z'Called when the given test has been runFN)_restoreStdoutr)   r7   s     r   stopTestTestResult.stopTestO   s    "r   c                    U R                   (       Gaj  U R                  (       a  [        R                  R	                  5       n[        R
                  R	                  5       nU(       a=  UR                  S5      (       d  US-  nU R                  R                  [        U-  5        U(       a=  UR                  S5      (       d  US-  nU R                  R                  [        U-  5        U R                  [        l        U R                  [        l        U R                  R                  S5        U R                  R                  5         U R                  R                  S5        U R                  R                  5         g g )N
r   )r    r)   r$   r%   getvaluer'   endswithr&   writeSTDOUT_LINEr(   STDERR_LINEr"   seektruncater#   )r   outputerrors      r   rC   TestResult._restoreStdoutT   s   ;;;!!,,.

++-!??400$))//f0DE >>$//))//e0CD..CJ..CJ$$Q'((*$$Q'((*% r   c                     g)z]Called once after all tests are executed.

See stopTest for a method called after each test.
Nr0   r1   s    r   stopTestRunTestResult.stopTestRuni   r4   r   c                 h    U R                   R                  XR                  X!5      45        SU l        g)z]Called 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   r8   errs      r   addErrorTestResult.addErroro   s,    
 	D":":3"EFG!r   c                 h    U R                   R                  XR                  X!5      45        SU l        g)z\Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info().TN)r   rV   rW   r)   rX   s      r   
addFailureTestResult.addFailurew   s,     	d$<$<S$GHI!r   c                    Ub  [        U SS5      (       a  U R                  5         [        US   UR                  5      (       a  U R                  nOU R
                  nUR                  X R                  X15      45        SU l        gg)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().
Nr	   Fr   T)	r
   r   
issubclassfailureExceptionr   r   rV   rW   r)   )r   r8   subtestrY   r   s        r   
addSubTestTestResult.addSubTest~   sq     ?tZ//		#a&$"7"788MM7$<$<S$GHI!%D r   c                     g)z-Called when a test has completed successfullyNr0   r7   s     r   
addSuccessTestResult.addSuccess   s    r   c                 <    U R                   R                  X45        g)zCalled when a test is skipped.N)r   rV   )r   r8   reasons      r   addSkipTestResult.addSkip   s    TN+r   c                 Z    U R                   R                  XR                  X!5      45        g)z/Called when an expected failure/error occurred.N)r   rV   rW   rX   s      r   addExpectedFailureTestResult.addExpectedFailure   s'    $$++C67	9r   c                 :    U R                   R                  U5        g)z5Called when a test was expected to fail, but succeed.N)r   rV   r7   s     r   addUnexpectedSuccessTestResult.addUnexpectedSuccess   s     	  ''-r   c                 t    [        U S5      (       a'  U R                  R                  [        U5      U45        gg)zCalled when a test finished to run, regardless of its outcome.
*test* is the test case corresponding to the test method.
*elapsed* is the time represented in seconds, and it includes the
execution of cleanup functions.
r   N)hasattrr   rV   str)r   r8   elapseds      r   addDurationTestResult.addDuration   s4     4-..##**CIw+?@ /r   c                     [        U R                  5      [        U R                  5      s=:H  =(       a    S:H  Os  =(       a0    [        U S5      (       + =(       d    [        U R                  5      S:H  $ )z/Tells whether or not this result was a success.r   r   )lenr   r   rs   r   r1   s    r   wasSuccessfulTestResult.wasSuccessful   sV    
 T]]#s4;;'7<<1< 5T#899 4T--.!3	6r   c                     SU l         g)z+Indicates that the tests should be aborted.TN)r   r1   s    r   r   TestResult.stop   s	    r   c                 H   Uu  p4nU R                  X4XR5      n[        R                  " X4UU R                  SS9n[	        UR                  5       5      nU R                  (       a  [        R                  R                  5       n[        R                  R                  5       n	U(       a3  UR                  S5      (       d  US-  nUR                  [        U-  5        U	(       a3  U	R                  S5      (       d  U	S-  n	UR                  [        U	-  5        SR                  U5      $ )z>Converts a sys.exc_info()-style tuple of values into a string.T)capture_localscompactrG    )_clean_tracebacks	tracebackTracebackExceptionr!   listformatr    r$   r%   rH   r'   rI   rV   rK   rL   join)
r   rY   r8   exctypevaluetbtb_emsgLinesrO   rP   s
             r   rW   TestResult._exc_info_to_string   s     ##GB=++B>>49 &;;ZZ((*FJJ'')Et,,dNFf 45~~d++TMEe 34wwx  r   c                 \   S nSnXU4/n[        U5      1nU(       Ga  UR                  5       u  pnU(       aA  U R                  U5      (       a+  UR                  nU(       a  U R                  U5      (       a  M+  XR                  L a  U R                  U5        U(       a  UnSnOX2l        Ubu  UR                  UR                  4 HY  n	U	c  M  [        U	5      U;  d  M  UR                  [        U	5      XR                  45        UR                  [        U	5      5        M[     U(       a  GM  U$ )NTF)idpop_is_relevant_tb_leveltb_nextra   _remove_unittest_tb_frames__traceback__	__cause____context__rV   typeadd)
r   r   r   r   r8   retfirstexcsseencs
             r   r   TestResult._clean_tracebacks   s    $%5	{#'88: WR33B77ZZ 33B77 /////3&(# //5+<+<=A}Ad):T!Wa$ABA ># d* 
r   c                 4    SUR                   R                  ;   $ )N
__unittest)tb_frame	f_globals)r   r   s     r   r    TestResult._is_relevant_tb_level   s    r{{4444r   c                     SnU(       aC  U R                  U5      (       d-  UnUR                  nU(       a  U R                  U5      (       d  M-  Ub  SUl        gg)zTruncates 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   prevs      r   r   %TestResult._remove_unittest_tb_frames   sS     33B77DB 33B77 DL r   c                     S[         R                  " U R                  5      U R                  [	        U R
                  5      [	        U R                  5      4-  $ )Nz!<%s run=%i errors=%i failures=%i>)r   strclass	__class__r   ry   r   r   r1   s    r   __repr__TestResult.__repr__   sA    3dnn-t}}c$++>NDMM"$$ 	%r   )r)   r(   r&   r#   r"   r    r   r   r   r	   r   r   r   r!   r   r   )NNN)!__name__
__module____qualname____firstlineno____doc___previousTestClass_testRunEntered_moduleSetUpFailedr-   r2   r9   r6   r@   rD   rC   rS   r	   rZ   r]   rc   rf   rj   rm   rp   rv   rz   r   rW   r   r   r   r   __static_attributes__r0   r   r   r   r      s    	 O#$.-#
+* " " " "&",9
 . .	A6!,85 %r   r   )r   r<   r$   r   r   r   	functoolsr   r   r	   rK   rL   objectr   r0   r   r   <module>r      s;     	 
   
 h% h%r   