+
    Dfjh                         R t ^ RIt^ RIHtHt ^ RIHtHt ^ RIH	t	H
t
Ht R t ! R R4      t ! R R	]P                  4      t ! R
 R4      t ! R R]]P                  4      t ! R R]]P$                  4      tR# )zG
Test the interaction between trial and errors logged during test run.
N)reactortask)failurelog)	_synctestreporterunittestc                 h     ^^ ,           X #   \          d    \        P                  ! 4       p  T # i ; i)z"
Return a new, realistic failure.
)ZeroDivisionErrorr   Failure)fs    =/usr/lib/python3/dist-packages/twisted/trial/test/test_log.pymakeFailurer      s7    	A H  OOHs   	  11c                       ] tR t^tRt ! R R4      t ! R R]]P                  4      t ! R R]]P                  4      t
RtR	# )
Maskz7
Hide C{MockTest}s from Trial's automatic test finder.
c                   8   a  ] tR t^t o R tR tR tR tRtV t	R# )Mask.FailureLoggingMixinc                    R# )z
Don't log any errors.
N selfs   &r   test_silent$Mask.FailureLoggingMixin.test_silent    s        c                B    \         P                  ! \        4       4       R# )z
Log a single error.
Nr   errr   r   s   &r   test_single$Mask.FailureLoggingMixin.test_single%   s     GGKM"r   c                ~    \         P                  ! \        4       4       \         P                  ! \        4       4       R# )z
Log two errors.
Nr   r   s   &r   test_double$Mask.FailureLoggingMixin.test_double+   s      GGKM"GGKM"r   c                T    \         P                  ! \        4       4       ^R,            R# )z 
Log a single error, then fail.
Nr   r   s   &r   test_singleThenFail,Mask.FailureLoggingMixin.test_singleThenFail2   s     GGKM"HHr   r   N)
__name__
__module____qualname____firstlineno__r   r   r    r#   __static_attributes____classdictcell____classdict__s   @r   FailureLoggingMixinr      s     	
	#	#	 	r   r-   c                       ] tR t^9tRtR# )Mask.SynchronousFailureLoggingr   N)r%   r&   r'   r(   r)   r   r   r   SynchronousFailureLoggingr/   9   s    r   r0   c                   &   a  ] tR t^<t o R tRtV tR# )Mask.AsynchronousFailureLoggingc                <    \         P                  ! \        ^ R 4      # )z+
Log an error in an asynchronous callback.
c                  >    \         P                  ! \        4       4      # Nr   r   r   r   <lambda>AMask.AsynchronousFailureLogging.test_inCallback.<locals>.<lambda>A   s    sww{}7Mr   )r   
deferLaterr   r   s   &r   test_inCallback/Mask.AsynchronousFailureLogging.test_inCallback=   s     ??7A/MNNr   r   N)r%   r&   r'   r(   r9   r)   r*   r+   s   @r   AsynchronousFailureLoggingr2   <   s     	O 	Or   r;   r   N)r%   r&   r'   r(   __doc__r-   r   SynchronousTestCaser0   TestCaser;   r)   r   r   r   r   r      sC     4$79U9U O%8(:K:K O Or   r   c                   T   a  ] tR t^Dt o RtR tR tR tR tR t	R t
R tR	 tR
tV tR# )ObserverTestszs
Tests for L{_synctest._LogObserver}, a helper for the implementation of
L{SynchronousTestCase.flushLoggedErrors}.
c                n    \         P                  ! 4       V n        \        P                  ! 4       V n        R # r5   )r   
TestResultresultr   _LogObserverobserverr   s   &r   setUpObserverTests.setUpJ   s"    ))+!..0r   c           
         V P                   P                  RRR\        P                  ! 4       R^ RR/4       V P                  V P                   P	                  4       . 4       R# )zG
Test that a standard log message doesn't go anywhere near the result.
messagetimeisErrorsystem-N)zsome message)rE   gotEventrJ   assertEqual	getErrorsr   s   &r   test_msgObserverTests.test_msgN   sU     	,		1#		
 	002B7r   c                    \        4       pV P                  P                  RR	R\        P                  ! 4       R^RRRVRR/4       V P	                  V P                  P                  4       V.4       R# )
z6
Test that an observed error gets added to the result
rI   rJ   rK   rL   rM   r   whyNr   )r   rE   rN   rJ   rO   rP   r   r   s   & r   
test_errorObserverTests.test_error\   sg     M2		1#1t		
 	002QC8r   c                :   V P                  4        V P                  P                  4       pV P                  V P                  P	                  4       . 4       V P                  \        V4      ^4       V P                  V^ ,          P                  \        4      4       R# )zC
Check that flushing the observer with no args removes all errors.
N)	rV   rE   flushErrorsrO   rP   len
assertTruecheckr
   )r   flusheds   & r   
test_flushObserverTests.test_flushm   sm     	--++-002B7Wq)
(():;<r   c                @    \         P                  ! \        R 4      4      # )z
test error)r   r   RuntimeErrorr   s   &r   _makeRuntimeFailure!ObserverTests._makeRuntimeFailurew   s    |L9::r   c                   V P                  4        V P                  4       pV P                  P                  \	        R\
        P
                  ! 4       ^RVRR7      4       V P                  P                  \        4      pV P                  V P                  P                  4       V.4       V P                  \        V4      ^4       V P                  V^ ,          P                  \        4      4       R# )zI
Check that flushing the observer remove all failures of the given type.
rM   N)rI   rJ   rK   rL   r   rT   r   )rV   rb   rE   rN   dictrJ   rY   r
   rO   rP   rZ   r[   r\   )r   r   r]   s   &  r   test_flushByTypeObserverTests.test_flushByTypez   s     	$$&aQTX	

 --++,=>002QC8Wq)
(():;<r   c                    V P                   P                  \        4       \        4       pV P                   P	                  RR	R\
        P
                  ! 4       R^RRRVRR/4       V P                  V P                   P                  4       . 4       R# )
zC
Check that C{_ignoreErrors} actually causes errors to be ignored.
rI   rJ   rK   rL   rM   r   rT   Nr   )rE   _ignoreErrorsr
   r   rN   rJ   rO   rP   rU   s   & r   test_ignoreErrorsObserverTests.test_ignoreErrors   sx     	##$56M2		1#1t		
 	002B7r   c                V   V P                   P                  \        4       V P                   P                  4        \	        4       pV P                   P                  RR	R\        P                  ! 4       R^RRRVRR/4       V P                  V P                   P                  4       V.4       R# )
zR
Check that C{_clearIgnores} ensures that previously ignored errors
get captured.
rI   rJ   rK   rL   rM   r   rT   Nr   )	rE   ri   r
   _clearIgnoresr   rN   rJ   rO   rP   rU   s   & r   test_clearIgnoresObserverTests.test_clearIgnores   s    
 	##$56##%M2		1#1t		
 	002QC8r   )rE   rC   N)r%   r&   r'   r(   r<   rF   rQ   rV   r^   rb   rf   rj   rn   r)   r*   r+   s   @r   r@   r@   D   s7     
189"=;= 8$9 9r   r@   c                   N   a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	tV tR
# )LogErrorsMixinzV
High-level tests demonstrating the expected behaviour of logged errors
during tests.
c                :    \         P                  ! 4       V n        R # r5   )r   rB   rC   r   s   &r   rF   LogErrorsMixin.setUp   s    ))+r   c                0    V P                  \        4       R # r5   )flushLoggedErrorsr
   r   s   &r   tearDownLogErrorsMixin.tearDown   s    01r   c                   V P                  R4      pV! V P                  4       V P                  \        V P                  P                  4      ^4       V P                  V P                  P                  ^ ,          ^,          P                  \        4      V P                  P                  ^ ,          ^,          4       V P                  ^ V P                  P                  4       R# )z9
Test that a logged error gets reported as a test error.
r   N)	MockTestrC   rO   rZ   errorsr[   r\   r
   	successesr   tests   & r   test_singleErrorLogErrorsMixin.test_singleError   s     }}]+T[[T[[//0!4KKq!!$**+<=t{{?Q?QRS?TUV?W	
 	DKK112r   c                    V P                  R4      pV! V P                  4       V P                  \        V P                  P                  4      ^4       V P                  ^ V P                  P
                  4       R# )zN
Test that when two errors get logged, they both get reported as test
errors.
r    Nry   rC   rO   rZ   rz   r{   r|   s   & r   test_twoErrorsLogErrorsMixin.test_twoErrors   sW    
 }}]+T[[T[[//0!4DKK112r   c                   V P                  R4      pV P                  R4      pV! V P                  4       V! V P                  4       V P                  \        V P                  P                  4      ^4       V P                  V P                  P                  ^ ,          ^ ,          V4       V P                  ^V P                  P
                  4       R# )zD
Check that an error logged in one test doesn't fail the next test.
r   r   Nr   r   t1t2s   &  r   test_errorsIsolated"LogErrorsMixin.test_errorsIsolated   s     ]]=)]]=)
4;;
4;;T[[//0!4++A.q126DKK112r   c                   V P                  R4      pV P                  R4      pV! V P                  4       V! V P                  4       V P                  \        V P                  P                  4      ^4       V P                  V P                  P                  ^ ,          ^ ,          V4       V P                  P                  ^ ,          ^,          P                  \        4       V P                  V P                  P                  ^,          ^ ,          V4       V P                  P                  ^,          ^,          P                  \        4       V P                  ^V P                  P                  4       R# )z>
An error logged in a failed test doesn't fail the next test.
r#   r   N)	ry   rC   rO   rZ   rz   trap	TypeErrorr
   r{   r   s   &  r    test_errorsIsolatedWhenTestFails/LogErrorsMixin.test_errorsIsolatedWhenTestFails   s     ]]01]]=)
4;;
4;;T[[//0!4++A.q1261a %%i0++A.q1261a %%&78DKK112r   c                8   \         P                  ! 4       pV P                  \         RV4       \        P                  P
                  R,          pV P                  4       pV! V P                  4       V P                  V\        P                  P
                  4       R# )z5
There are no extra log observers after a test runs.
_logObserver:NNNN)	r   rD   patchr   theLogPublisher	observersry   rC   rO   )r   rE   r   r}   s   &   r   test_boundedObservers$LogErrorsMixin.test_boundedObservers   sk    
 ))+

9nh7''11!4	}}T[[C$7$7$A$ABr   )rC   N)r%   r&   r'   r(   r<   rF   rv   r~   r   r   r   r   r)   r*   r+   s   @r   rq   rq      s4     
,2
33
33$
C 
Cr   rq   c                   .    ] tR t^t]P
                  tRtR# )SynchronousLogErrorsTestsr   N)r%   r&   r'   r(   r   r0   ry   r)   r   r   r   r   r      s    --Hr   r   c                   >   a  ] tR tRt o ]P
                  tR tRtV t	R# )AsynchronousLogErrorsTestsi  c                |   V P                  R4      pV! V P                  4       V P                  \        V P                  P                  4      ^4       V P                  V P                  P                  ^ ,          ^,          P                  \        4      V P                  P                  ^ ,          ^,          4       R# )zC
Test that errors logged in callbacks get reported as test errors.
r9   N)ry   rC   rO   rZ   rz   r[   r\   r
   r|   s   & r   r9   *AsynchronousLogErrorsTests.test_inCallback  s     }}./T[[T[[//0!4KKq!!$**+<=t{{?Q?QRS?TUV?W	
r   r   N)
r%   r&   r'   r(   r   r;   ry   r9   r)   r*   r+   s   @r   r   r     s     ..H	
 	
r   r   )r<   rJ   twisted.internetr   r   twisted.pythonr   r   twisted.trialr   r   r   r   r   r=   r@   rq   r   r>   r   r   r   r   <module>r      sy     * ' 7 7'O 'OTj9H00 j9ZJC JCZ.0L0L .
1B1B 
r   