+
    DfjJ-                     2   R t ^ RIHt ^ RIHtHtHtHtHtH	t	 ^ RI
Ht ^ RIHtHt ^ RIHt ^ RIHtHt ^ RIHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^RIH t  ^RI!H"t"H!t! ]	! R4      t#R R lt$R R lt%R R lt&] ! R R4      4       t' ! R R]4      t(R# )zZ
Test reporter forwarding test results over trial distributed AMP commands.

@since: 12.3
)TracebackType)CallableListOptionalSequenceTypeTypeVar)TestCase)Factorydefine)Literal)DeferredmaybeDeferred)AMPMAX_VALUE_LENGTH)Failure)qual)managercommands)
TestResult)TrialFailure)chunkstreamTc                n    V ^8  d   QhR\         R\        R\        R\        R\        \        ,          RR/# )   amptestName
errorClasserrorframesreturnNr   strr   )formats   "D/usr/lib/python3/dist-packages/twisted/trial/_dist/workerreporter.py__annotate__r%      s@      	),58BFs)	    c                
  "   \        V \        VP                  R4      \        4      4      G Rj  xL
 p\        V R V 4       4      G Rj  xL
 pV P	                  \
        P                  VVVVR7      G Rj  xL
  R#  LM L4 L
5i)a  
Send an error to the worker manager over an AMP connection.

First the pieces which can be large are streamed over the connection.
Then, L{managercommands.AddError} is called with the rest of the
information and the stream IDs.

@param amp: The connection to use.
@param testName: The name (or ID) of the test the error relates to.
@param errorClass: The fully qualified name of the error type.
@param error: The string representation of the error.
@param frames: The lines of the traceback associated with the error.
utf-8Nc              3   B   "   T F  qP                  R 4      x  K  	  R# 5ir(   Nencode.0frames   & r$   	<genexpr>addError.<locals>.<genexpr>1        'R6%W(=(=6   )r   r   errorStreamIdframesStreamId)r   r   r,   r   
callRemoter   AddError)r   r   r   r   r   r4   r5   s   &&&&&  r$   addErrorr8      sz     " !eELL,ACS&TUUM!#'R6'RSSN
..  #%     VS3   -BA=B
A?+B6B7B?BBc                n    V ^8  d   QhR\         R\        R\        R\        R\        \        ,          RR/# )r   r   r   fail	failClassr   r    Nr!   )r#   s   "r$   r%   r%   <   s@      	#&36@DS		r&   c                
  "   \        V \        VP                  R4      \        4      4      G Rj  xL
 p\        V R V 4       4      G Rj  xL
 pV P	                  \
        P                  VVVVR7      G Rj  xL
  R#  LM L4 L
5i)a;  
Like L{addError} but for failures.

@param amp: See L{addError}
@param testName: See L{addError}
@param failClass: The fully qualified name of the exception associated
    with the failure.
@param fail: The string representation of the failure.
@param frames: The lines of the traceback associated with the error.
r(   Nc              3   B   "   T F  qP                  R 4      x  K  	  R# 5ir*   r+   r-   s   & r$   r0   addFailure.<locals>.<genexpr>J   r2   r3   )r   r<   failStreamIdr5   )r   r   r,   r   r6   r   
AddFailure)r   r   r;   r<   r   r@   r5   s   &&&&&  r$   
addFailurerB   <   sz       U4;;w+?AQ%RSSL!#'R6'RSSN
..""!%     TSr9   c          
      L    V ^8  d   QhR\         R\        R\        R\        RR/# )r   r   r   r   todor    N)r   r"   )r#   s   "r$   r%   r%   U   s0      #  S  PT r&   c                   "   \        V \        VP                  R4      \        4      4      G Rj  xL
 pV P	                  \
        P                  VVVR7      G Rj  xL
  R#  L1 L5i)z
Like L{addError} but for expected failures.

@param amp: See L{addError}
@param testName: See L{addError}
@param error: The string representation of the expected failure.
@param todo: The string description of the expectation.
r(   N)r   r4   rD   )r   r   r,   r   r6   r   AddExpectedFailure)r   r   r   rD   r4   s   &&&& r$   addExpectedFailurerG   U   s_      !eELL,ACS&TUUM
..**#	     Vs!   -A%A!*A%A#A%#A%c                   v   a  ] tR t^ht o Rt]! ]4      tV 3R lR ltV 3R lR lt	V 3R lR lt
V 3R ltR	tV tR
# )ReportingResultsaC  
A mutable container for the result of sending test results back to the
parent process.

Since it is possible for these sends to fail asynchronously but the
L{TestResult} protocol is not well suited for asynchronous result
reporting, results are collected on an instance of this class and when the
runner believes the test is otherwise complete, it can collect the results
and do something with any errors.

@ivar _reporter: The L{WorkerReporter} this object is associated with.
    This is the object doing the result reporting.

@ivar _results: A list of L{Deferred} instances representing the results
    of reporting operations.  This is expected to grow over the course of
    the test run and then be inspected by the runner once the test is
    over.  The public interface to this list is via the context manager
    interface.
c                @   < V ^8  d   QhRS[ S[S[,          ,          /# r   r    )r   r   object)r#   __classdict__s   "r$   r%   ReportingResults.__annotate__   s     
 
8HV$45 
r&   c                    V P                   # )ad  
Begin a new reportable context in which results can be collected.

@return: A sequence which will contain the L{Deferred} instances
    representing the results of all test result reporting that happens
    while the context manager is active.  The sequence is extended as
    the test runs so its value should not be consumed until the test
    is over.
)_resultsselfs   &r$   	__enter__ReportingResults.__enter__   s     }}r&   c          	      P   < V ^8  d   QhRS[ S[,          RS[RS[RS[R,          /# )r   excTypeexcValueexcTracebackr    F)r   BaseExceptionr   r   )r#   rM   s   "r$   r%   rN      s<     
 
m$
  
 $	

 

r&   c                (    RV P                   n        R# )z
End the reportable context.
NF)	_reporter
_reporting)rR   rV   rW   rX   s   &&&&r$   __exit__ReportingResults.__exit__   s     %)!r&   c                4   < V ^8  d   QhRS[ S[,          RR/# )r   resultr    N)r   rL   )r#   rM   s   "r$   r%   rN      s      % %Xf- %$ %r&   c                <    V P                   P                  V4       R# )zQ
Record a L{Deferred} instance representing one test result reporting
operation.
N)rP   append)rR   r`   s   &&r$   recordReportingResults.record   s    
 	V$r&   c                P   < V ^8  d   Qh/ R;R&   S[ S[S[,          ,          ;R&   # )r   WorkerReporterr[   rP   )r   r   rL   )r#   rM   s   "r$   r%   rN   h   s)     ,  - . 8F#$4/ r&    N)__name__
__module____qualname____firstlineno____doc__r
   listrP   rS   r]   rc   __annotate_func____static_attributes____classdictcell__)rM   s   @r$   rI   rI   h   s;     * (/t}H
 

 
% %c  r&   rI   c                   $  a a ] tR t^t oRtRtRtV 3R ltV3R lR ltV3R lR lt	V3R	 lR
 lt
V3R lR ltV3R lV 3R lltV3R lR ltV3R lV 3R lltV3R lV 3R lltV 3R ltR tRV 3R lltRV 3R lltR tV3R ltRtVtV ;t# )rf   a  
Reporter for trial's distributed workers. We send things not through a
stream, but through an C{AMP} protocol's C{callRemote} method.

@ivar _DEFAULT_TODO: Default message for expected failures and
    unexpected successes, used only if a C{Todo} is not provided.

@ivar _reporting: When a "result reporting" context is active, the
    corresponding context manager.  Otherwise, L{None}.
zTest expected to failNc                0   < \         SV `  4        Wn        R# )zw
@param ampProtocol: The communication channel with the trial
    distributed manager which collects all test results.
N)super__init__ampProtocol)rR   ru   	__class__s   &&r$   rt   WorkerReporter.__init__   s    
 	&r&   c                    < V ^8  d   QhRS[ /# rK   )rI   )r#   rM   s   "r$   r%   WorkerReporter.__annotate__   s     	 	(8 	r&   c                :    \        V 4      V n        V P                  # )z
Get a "result reporting" context manager.

In a "result reporting" context, asynchronous test result reporting
methods may be used safely.  Their results (in particular, failures)
are available from the context manager.
)rI   r\   rQ   s   &r$   gatherReportingResults%WorkerReporter.gatherReportingResults   s     +40r&   c                &   < V ^8  d   QhRS[ RS[/# )r   r   r    )r   r   )r#   rM   s   "r$   r%   ry      s       ' r&   c                v    \        V\        4      '       d#   \        V^,          V^ ,          V^,          4      # V# )zH
Convert a C{sys.exc_info()}-style tuple to a L{Failure}, if necessary.
)
isinstancetupler   )rR   r   s   &&r$   _getFailureWorkerReporter._getFailure   s1     eU##58U1XuQx88r&   c                6   < V ^8  d   QhRS[ RS[S[,          /# )r   failurer    )r   r   r"   )r#   rM   s   "r$   r%   ry      s     	 	' 	d3i 	r&   c           	         . pVP                    F5  pVP                  V^ ,          V^,          \        V^,          4      .4       K7  	  V# )z,
Extract frames from a C{Failure} instance.
)r   extendr"   )rR   r   r   r/   s   &&  r$   
_getFramesWorkerReporter._getFrames   sC     ^^E MM58U1Xs58}=> $ r&   c                8   < V ^8  d   QhRS[ . S[3,          RR/# )r   fr    N)r   r   )r#   rM   s   "r$   r%   ry      s#      xA 4 r&   c                    V P                   e'   V P                   P                  \        V4      4       R# \        R4      h)aS  
Call L{f} if and only if a "result reporting" context is active.

@param f: A function to call.  Its result is accumulated into the
    result reporting context.  It may return a L{Deferred} or a
    coroutine or synchronously raise an exception or return a result
    value.

@raise ValueError: If no result reporting context is active.
Nz9Cannot call command outside of reporting context manager.)r\   rc   r   
ValueError)rR   r   s   &&r$   _callWorkerReporter._call   s5     ??&OO""=#34K r&   c                $   < V ^8  d   QhRS[ RR/# )r   testr    N)PyUnitTestCase)r#   rM   s   "r$   r%   ry      s     
 
~ 
$ 
r&   c                v   <a a \         SS `  V4       VP                  4       oS P                  V V3R l4       R# )zm
Send a success to the parent process.

This must be called in context managed by L{gatherReportingResults}.
c                  Z   < S P                   P                  \        P                  SR 7      # ))r   )ru   r6   r   
AddSuccess)rR   r   s   r$   <lambda>+WorkerReporter.addSuccess.<locals>.<lambda>   s&    D$$//**X 0 r&   N)rs   
addSuccessidr   )rR   r   r   rv   s   f&@r$   r   WorkerReporter.addSuccess   s.     	4 779

	
r&   c                *   < V ^8  d   QhRS[ RS[RR/# )r   r   errorObjr    N)r"   r   )r#   rM   s   "r$   r%   ry      s"     
 
s 
l 
t 
r&   c                   "   V P                  V4      pVP                  4       p\        VP                  4      pV P	                  V4      p\        V P                  VVVV4      G Rj  xL
  R#  L5i)z
Attempt to report an error to the parent process.

Unlike L{addError} this can fail asynchronously.  This version is for
infrastructure code that can apply its own failure handling.

@return: A L{Deferred} that fires with the result of the attempt.
N)r   getErrorMessager   typer   r8   ru   )rR   r   r   r   errorStrr   r   s   &&&    r$   addErrorFallibleWorkerReporter.addErrorFallible   sh      ""8,**,',,'
)
 	
 	
s   A$A/&A-'A/c                *   < V ^8  d   QhRS[ RS[RR/# )r   r   r   r    Nr   r   )r#   rM   s   "r$   r%   ry     s'     C C^ CL CT Cr&   c                |   <a aa \         SS `  VS4       VP                  4       oS P                  VV V3R l4       R# )z&
Send an error to the parent process.
c                  (   < SP                  SS 4      # N)r   )r   rR   r   s   r$   r   )WorkerReporter.addError.<locals>.<lambda>  s    4005Ar&   N)rs   r8   r   r   )rR   r   r   r   rv   s   f&f@r$   r8   WorkerReporter.addError  s,     	u%779

ABr&   c                *   < V ^8  d   QhRS[ RS[RR/# )r   r   r;   r    Nr   )r#   rM   s   "r$   r%   ry     s"     
 
~ 
\ 
d 
r&   c                  <a aaaa \         SS `  W4       VP                  4       oS P                  V4      pVP	                  4       o\        VP                  4      oS P                  V4      oS P                  VVVV V3R l4       R# )z
Send a Failure over.
c                  6   < \        SP                  SSS S4      # r   )rB   ru   )r<   failureMessager   rR   r   s   r$   r   +WorkerReporter.addFailure.<locals>.<lambda>   s    J  r&   N)	rs   rB   r   r   r   r   r   r   r   )	rR   r   r;   r   r<   r   r   r   rv   s	   f&& @@@@r$   rB   WorkerReporter.addFailure  sm     	4&779""4( 002&	)

 	
r&   c                   <a aa \         SS `  VS4       \        S4      oVP                  4       oS P	                  VV V3R l4       R# )z
Send a skip over.
c                  \   < SP                   P                  \        P                  SS R 7      # ))r   reason)ru   r6   r   AddSkip)r   rR   r   s   r$   r   (WorkerReporter.addSkip.<locals>.<lambda>1  s(    D$$//''(6 0 r&   N)rs   addSkipr"   r   r   )rR   r   r   r   rv   s   f&f@r$   r   WorkerReporter.addSkip)  s8     	f%V779

	
r&   c                :    Vf   V P                   # VP                  # )zR
Get the reason for a C{Todo}.

If C{todo} is L{None}, return a sensible default.
)_DEFAULT_TODOr   )rR   rD   s   &&r$   _getTodoReasonWorkerReporter._getTodoReason6  s     <%%%;;r&   c                   <a aaa \         SS `  WS4       VP                  4       oVP                  4       oS P	                  VV VV3R l4       R# )z 
Send an expected failure over.
c                  T   < \        SP                  SS SP                  S4      R 7      # ))r   r   rD   )rG   ru   r   )errorMessagerR   r   rD   s   r$   r   3WorkerReporter.addExpectedFailure.<locals>.<lambda>I  s(    &  !"((.	r&   N)rs   rG   r   r   r   )rR   r   r   rD   r   r   rv   s   f&&f@@r$   rG   !WorkerReporter.addExpectedFailureA  s>     	"45,,.779

	
r&   c                |   <a aa \         SS `  VS4       VP                  4       oS P                  V VV3R l4       R# )z"
Send an unexpected success over.
c                  z   < S P                   P                  \        P                  SS P	                  S4      R 7      # ))r   rD   )ru   r6   r   AddUnexpectedSuccessr   )rR   r   rD   s   r$   r   5WorkerReporter.addUnexpectedSuccess.<locals>.<lambda>X  s5    D$$//44!((. 0 r&   N)rs   addUnexpectedSuccessr   r   )rR   r   rD   r   rv   s   f&f@r$   r   #WorkerReporter.addUnexpectedSuccessQ  s0     	$T40779

	
r&   c                    R# )z
I{Don't} print a summary
Nrg   rQ   s   &r$   printSummaryWorkerReporter.printSummary_  s    r&   c                B   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   # )r   ru   r\   )r   r   rI   )r#   rM   s   "r$   r%   ry      s%        )*1 r&   )r\   ru   r   )rh   ri   rj   rk   rl   r   r\   rt   r{   r   r   r   r   r   r8   rB   r   r   rG   r   r   rn   ro   rp   __classcell__)rv   rM   s   @@r$   rf   rf      s     	 ,M .2J'	 	 	 	 $
 

 
*C C
 
(
	
 
}  r&   rf   N))rl   typesr   typingr   r   r   r   r   r   unittestr	   r   attrsr
   r   r   twisted.internet.deferr   r   twisted.protocols.ampr   r   twisted.python.failurer   twisted.python.reflectr   twisted.trial._distr   twisted.trial.reporterr   reporterr   r   r   r   r8   rB   rG   rI   rf   rg   r&   r$   <module>r      sv      D D / !  : 7 * ' / - # !CL:2& 5% 5% 5%pAZ Ar&   