Ë
    ojh  ã                   óô   — d Z ddlZddlmZmZ ddlmZmZ ddlm	Z	m
Z
mZ d„ Z G d„ d«      Z G d	„ d
ej                  «      Z G d„ d«      Z G d„ deej                  «      Z G d„ deej$                  «      Zy)zG
Test the interaction between trial and errors logged during test run.
é    N)ÚreactorÚtask)ÚfailureÚlog)Ú	_synctestÚreporterÚunittestc                  óZ   — 	 ddz    S # t         $ r t        j                  «       } Y | S w xY w)z*
    Return a new, realistic failure.
    é   r   )ÚZeroDivisionErrorr   ÚFailure)Úfs    ú=/usr/lib/python3/dist-packages/twisted/trial/test/test_log.pyÚmakeFailurer      s7   € ðØ	ˆAŠð €Høô ò Ü�O‰OÓ‰Ø€Hðús   ‚	 ‰*©*c                   ó|   — e Zd ZdZ G d„ d«      Z G d„ deej                  «      Z G d„ deej                  «      Z	y)	ÚMaskz?
    Hide C{MockTest}s from Trial's automatic test finder.
    c                   ó$   — e Zd Zd„ Zd„ Zd„ Zd„ Zy)úMask.FailureLoggingMixinc                  ó   — y)z/
            Don't log any errors.
            N© ©Úselfs    r   Útest_silentz$Mask.FailureLoggingMixin.test_silent    s   � ó    c                 ó>   — t        j                  t        «       «       y)z-
            Log a single error.
            N©r   Úerrr   r   s    r   Útest_singlez$Mask.FailureLoggingMixin.test_single%   s   € ô �G‰G”K“MÕ"r   c                 óx   — t        j                  t        «       «       t        j                  t        «       «       y)z)
            Log two errors.
            Nr   r   s    r   Útest_doublez$Mask.FailureLoggingMixin.test_double+   s    € ô �G‰G”K“MÔ"Ü�G‰G”K“MÕ"r   c                 óH   — t        j                  t        «       «       ddz    y)z8
            Log a single error, then fail.
            r   Nr   r   s    r   Útest_singleThenFailz,Mask.FailureLoggingMixin.test_singleThenFail2   s   € ô �G‰G”K“MÔ"Ø�‹Hr   N)Ú__name__Ú
__module__Ú__qualname__r   r   r    r"   r   r   r   ÚFailureLoggingMixinr      s   „ ò	ò
	#ò	#ó	r   r&   c                   ó   — e Zd Zy)úMask.SynchronousFailureLoggingN)r#   r$   r%   r   r   r   ÚSynchronousFailureLoggingr(   9   s   „ Ør   r)   c                   ó   — e Zd Zd„ Zy)úMask.AsynchronousFailureLoggingc                 ó:   — t        j                  t        dd„ «      S )zC
            Log an error in an asynchronous callback.
            r   c                  ó<   — t        j                  t        «       «      S ©Nr   r   r   r   ú<lambda>zAMask.AsynchronousFailureLogging.test_inCallback.<locals>.<lambda>A   s   € ´s·w±w¼{»}Ó7M€ r   )r   Ú
deferLaterr   r   s    r   Útest_inCallbackz/Mask.AsynchronousFailureLogging.test_inCallback=   s   € ô —?‘?¤7¨AÑ/MÓNÐNr   N)r#   r$   r%   r1   r   r   r   ÚAsynchronousFailureLoggingr+   <   s   „ ó	Or   r2   N)
r#   r$   r%   Ú__doc__r&   r	   ÚSynchronousTestCaser)   ÚTestCaser2   r   r   r   r   r      s=   „ ñ÷ñ ô4Ð$7¸×9UÑ9Uô ôOÐ%8¸(×:KÑ:Kõ Or   r   c                   ó@   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zy
)ÚObserverTestsz
    Tests for L{_synctest._LogObserver}, a helper for the implementation of
    L{SynchronousTestCase.flushLoggedErrors}.
    c                 óh   — t        j                  «       | _        t        j                  «       | _        y r.   )r   Ú
TestResultÚresultr   Ú_LogObserverÚobserverr   s    r   ÚsetUpzObserverTests.setUpJ   s"   € Ü×)Ñ)Ó+ˆŒÜ!×.Ñ.Ó0ˆ�r   c                 ó¼   — | j                   j                  dt        j                  «       dddœ«       | j                  | j                   j	                  «       g «       y)zW
        Test that a standard log message doesn't go anywhere near the result.
        )zsome messager   ú-)ÚmessageÚtimeÚisErrorÚsystemN)r<   ÚgotEventrA   ÚassertEqualÚ	getErrorsr   s    r   Útest_msgzObserverTests.test_msgN   sL   € ð 	�‰×Ñà,ÜŸ	™	›ØØñ	ô	
ð 	×Ñ˜Ÿ™×0Ñ0Ó2°BÕ7r   c           	      óÖ   — t        «       }| j                  j                  dt        j                  «       dd|ddœ«       | j	                  | j                  j                  «       |g«       y)zF
        Test that an observed error gets added to the result
        r   r   r?   N©r@   rA   rB   rC   r   Úwhy)r   r<   rD   rA   rE   rF   ©r   r   s     r   Ú
test_errorzObserverTests.test_error\   s[   € ô ‹MˆØ�‰×ÑàÜŸ	™	›ØØØØñô		
ð 	×Ñ˜Ÿ™×0Ñ0Ó2°Q°CÕ8r   c                 ó0  — | j                  «        | j                  j                  «       }| j                  | j                  j	                  «       g «       | j                  t        |«      d«       | j                  |d   j                  t        «      «       y)zS
        Check that flushing the observer with no args removes all errors.
        r   r   N)	rL   r<   ÚflushErrorsrE   rF   ÚlenÚ
assertTrueÚcheckr   )r   Úflusheds     r   Ú
test_flushzObserverTests.test_flushm   sm   € ð 	�‰ÔØ—-‘-×+Ñ+Ó-ˆØ×Ñ˜Ÿ™×0Ñ0Ó2°BÔ7Ø×Ñœ˜W› qÔ)Ø�‰˜ ™
×(Ñ(Ô):Ó;Õ<r   c                 ó>   — t        j                  t        d«      «      S )Nz
test error)r   r   ÚRuntimeErrorr   s    r   Ú_makeRuntimeFailurez!ObserverTests._makeRuntimeFailurew   s   € Ü�‰œ|¨LÓ9Ó:Ð:r   c           
      óÔ  — | j                  «        | j                  «       }| j                  j                  t	        dt        j
                  «       dd|d¬«      «       | j                  j                  t        «      }| j                  | j                  j                  «       |g«       | j                  t        |«      d«       | j                  |d   j                  t        «      «       y)zY
        Check that flushing the observer remove all failures of the given type.
        r   r   r?   NrI   r   )rL   rV   r<   rD   ÚdictrA   rN   r   rE   rF   rO   rP   rQ   )r   r   rR   s      r   Útest_flushByTypezObserverTests.test_flushByTypez   s°   € ð 	�‰ÔØ×$Ñ$Ó&ˆØ�‰×ÑÜØ¤§¡£°aÀÈQÐTXôô	
ð
 —-‘-×+Ñ+Ô,=Ó>ˆØ×Ñ˜Ÿ™×0Ñ0Ó2°Q°CÔ8Ø×Ñœ˜W› qÔ)Ø�‰˜ ™
×(Ñ(Ô):Ó;Õ<r   c           	      ó  — | j                   j                  t        «       t        «       }| j                   j	                  dt        j
                  «       dd|ddœ«       | j                  | j                   j                  «       g «       y)zS
        Check that C{_ignoreErrors} actually causes errors to be ignored.
        r   r   r?   NrI   )r<   Ú_ignoreErrorsr   r   rD   rA   rE   rF   rK   s     r   Útest_ignoreErrorszObserverTests.test_ignoreErrorsŠ   sl   € ð 	�‰×#Ñ#Ô$5Ô6Ü‹MˆØ�‰×ÑàÜŸ	™	›ØØØØñô		
ð 	×Ñ˜Ÿ™×0Ñ0Ó2°BÕ7r   c           	      óH  — | j                   j                  t        «       | j                   j                  «        t	        «       }| j                   j                  dt        j                  «       dd|ddœ«       | j                  | j                   j                  «       |g«       y)zj
        Check that C{_clearIgnores} ensures that previously ignored errors
        get captured.
        r   r   r?   NrI   )	r<   r[   r   Ú_clearIgnoresr   rD   rA   rE   rF   rK   s     r   Útest_clearIgnoreszObserverTests.test_clearIgnoresœ   s~   € ð
 	�‰×#Ñ#Ô$5Ô6Ø�‰×#Ñ#Ô%Ü‹MˆØ�‰×ÑàÜŸ	™	›ØØØØñô		
ð 	×Ñ˜Ÿ™×0Ñ0Ó2°Q°CÕ8r   N)r#   r$   r%   r3   r=   rG   rL   rS   rV   rY   r\   r_   r   r   r   r7   r7   D   s/   „ ñò
1ò8ò9ò"=ò;ò=ò 8ó$9r   r7   c                   ó:   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
y	)
ÚLogErrorsMixinzb
    High-level tests demonstrating the expected behaviour of logged errors
    during tests.
    c                 ó6   — t        j                  «       | _        y r.   )r   r9   r:   r   s    r   r=   zLogErrorsMixin.setUp·   s   € Ü×)Ñ)Ó+ˆ�r   c                 ó.   — | j                  t        «       y r.   )ÚflushLoggedErrorsr   r   s    r   ÚtearDownzLogErrorsMixin.tearDownº   s   € Ø×ÑÔ0Õ1r   c                 ó¦  — | j                  d«      } || j                  «       | j                  t        | j                  j                  «      d«       | j                  | j                  j                  d   d   j                  t        «      | j                  j                  d   d   «       | j                  d| j                  j                  «       y)zI
        Test that a logged error gets reported as a test error.
        r   r   r   N)	ÚMockTestr:   rE   rO   ÚerrorsrP   rQ   r   Ú	successes©r   Útests     r   Útest_singleErrorzLogErrorsMixin.test_singleError½   s    € ð �}‰}˜]Ó+ˆÙˆT�[‰[ÔØ×Ñœ˜TŸ[™[×/Ñ/Ó0°!Ô4Ø�‰Ø�K‰K×Ñ˜qÑ! !Ñ$×*Ñ*Ô+<Ó=¸t¿{¹{×?QÑ?QÐRSÑ?TÐUVÑ?Wô	
ð 	×Ñ˜˜DŸK™K×1Ñ1Õ2r   c                 óô   — | j                  d«      } || j                  «       | j                  t        | j                  j                  «      d«       | j                  d| j                  j
                  «       y)zf
        Test that when two errors get logged, they both get reported as test
        errors.
        r    é   r   N©rg   r:   rE   rO   rh   ri   rj   s     r   Útest_twoErrorszLogErrorsMixin.test_twoErrorsÉ   sW   € ð
 �}‰}˜]Ó+ˆÙˆT�[‰[ÔØ×Ñœ˜TŸ[™[×/Ñ/Ó0°!Ô4Ø×Ñ˜˜DŸK™K×1Ñ1Õ2r   c                 ó’  — | j                  d«      }| j                  d«      } || j                  «        || j                  «       | j                  t        | j                  j                  «      d«       | j                  | j                  j                  d   d   |«       | j                  d| j                  j
                  «       y)zT
        Check that an error logged in one test doesn't fail the next test.
        r   r   r   r   Nro   ©r   Út1Út2s      r   Útest_errorsIsolatedz"LogErrorsMixin.test_errorsIsolatedÓ   s“   € ð �]‰]˜=Ó)ˆØ�]‰]˜=Ó)ˆÙ
ˆ4�;‰;ŒÙ
ˆ4�;‰;ŒØ×Ñœ˜TŸ[™[×/Ñ/Ó0°!Ô4Ø×Ñ˜Ÿ™×+Ñ+¨AÑ.¨qÑ1°2Ô6Ø×Ñ˜˜DŸK™K×1Ñ1Õ2r   c                 ó¦  — | j                  d«      }| j                  d«      } || j                  «        || j                  «       | j                  t        | j                  j                  «      d«       | j                  | j                  j                  d   d   |«       | j                  j                  d   d   j                  t        «       | j                  | j                  j                  d   d   |«       | j                  j                  d   d   j                  t        «       | j                  d| j                  j                  «       y)zN
        An error logged in a failed test doesn't fail the next test.
        r"   r   rn   r   r   N)	rg   r:   rE   rO   rh   ÚtrapÚ	TypeErrorr   ri   rr   s      r   Ú test_errorsIsolatedWhenTestFailsz/LogErrorsMixin.test_errorsIsolatedWhenTestFailsß   sý   € ð �]‰]Ð0Ó1ˆØ�]‰]˜=Ó)ˆÙ
ˆ4�;‰;ŒÙ
ˆ4�;‰;Œà×Ñœ˜TŸ[™[×/Ñ/Ó0°!Ô4Ø×Ñ˜Ÿ™×+Ñ+¨AÑ.¨qÑ1°2Ô6Ø�‰×Ñ˜1Ñ˜aÑ ×%Ñ%¤iÔ0à×Ñ˜Ÿ™×+Ñ+¨AÑ.¨qÑ1°2Ô6Ø�‰×Ñ˜1Ñ˜aÑ ×%Ñ%Ô&7Ô8à×Ñ˜˜DŸK™K×1Ñ1Õ2r   c                 ó,  — t        j                  «       }| j                  t         d|«       t        j                  j
                  dd }| j                  «       } || j                  «       | j                  |t        j                  j
                  «       y)zE
        There are no extra log observers after a test runs.
        Ú_logObserverN)	r   r;   Úpatchr   ÚtheLogPublisherÚ	observersrg   r:   rE   )r   r<   r~   rk   s       r   Útest_boundedObserversz$LogErrorsMixin.test_boundedObserversñ   sk   € ô
 ×)Ñ)Ó+ˆØ�
‰
”9˜n¨hÔ7Ü×'Ñ'×1Ñ1±!Ð4ˆ	Ø�}‰}‹ˆÙˆT�[‰[ÔØ×Ñ˜¤C×$7Ñ$7×$AÑ$AÕBr   N)r#   r$   r%   r3   r=   re   rl   rp   ru   ry   r   r   r   r   ra   ra   ±   s+   „ ñò
,ò2ò
3ò3ò
3ò3ó$
Cr   ra   c                   ó$   — e Zd Zej                  Zy)ÚSynchronousLogErrorsTestsN)r#   r$   r%   r   r)   rg   r   r   r   r�   r�   þ   s   „ Ø×-Ñ-�Hr   r�   c                   ó*   — e Zd Zej                  Zd„ Zy)ÚAsynchronousLogErrorsTestsc                 óZ  — | j                  d«      } || j                  «       | j                  t        | j                  j                  «      d«       | j                  | j                  j                  d   d   j                  t        «      | j                  j                  d   d   «       y)zS
        Test that errors logged in callbacks get reported as test errors.
        r1   r   r   N)rg   r:   rE   rO   rh   rP   rQ   r   rj   s     r   r1   z*AsynchronousLogErrorsTests.test_inCallback  s…   € ð �}‰}Ð.Ó/ˆÙˆT�[‰[ÔØ×Ñœ˜TŸ[™[×/Ñ/Ó0°!Ô4Ø�‰Ø�K‰K×Ñ˜qÑ! !Ñ$×*Ñ*Ô+<Ó=¸t¿{¹{×?QÑ?QÐRSÑ?TÐUVÑ?Wõ	
r   N)r#   r$   r%   r   r2   rg   r1   r   r   r   rƒ   rƒ     s   „ Ø×.Ñ.€Hó	
r   rƒ   )r3   rA   Útwisted.internetr   r   Útwisted.pythonr   r   Útwisted.trialr   r   r	   r   r   r4   r7   ra   r�   r5   rƒ   r   r   r   ú<module>rˆ      sy   ðñó ç *ß 'ß 7Ñ 7ò÷'Oñ 'OôTj9�H×0Ñ0ô j9÷ZJCñ JCôZ. °×0LÑ0Lô .ô
 °×1BÑ1Bõ 
r   