Ë
    ojÁ  ã                   óL  — d Z ddlmZ ddlmZmZmZ ddlmZ ddl	mZm
Z
  G d„ de«      Z G d„ d	e«      Z G d
„ d«      Z G d„ deej                  «      Z G d„ deej"                  «      Z G d„ d«      Z G d„ deej                  «      Z G d„ deej"                  «      Z G d„ d«      Z G d„ deej                  «      Z G d„ deej"                  «      Z G d„ dej                  «      Z G d„ dej"                  «      Z G d „ d!ej                  «      Z ed"d#«       G d$„ d%ej                  «      «       Z G d&„ d'ej"                  «      Z G d(„ d)ej"                  «      Z G d*„ d+ej"                  «      Z G d,„ d-ej"                  «      Z d.„ Z! G d/„ d0ej                  «      Z"y1)2aJ  
Definitions of test cases with various interesting error-related behaviors, to
be used by test modules to exercise different features of trial's test runner.

See the L{twisted.trial.test.test_tests} module docstring for details about how
this code is arranged.

Some of these tests are also used by L{twisted.trial._dist.test}.
é    )ÚskipIf)ÚdeferÚprotocolÚreactor)Ú
deferLater)ÚunittestÚutilc                   ó   — e Zd Zy)ÚFoolishErrorN©Ú__name__Ú
__module__Ú__qualname__© ó    ú>/usr/lib/python3/dist-packages/twisted/trial/test/erroneous.pyr   r      ó   „ Ør   r   c                   ó&   — e Zd ZdZdeddfd„Zd„ Zy)Ú
LargeErrorzj
    An exception which has a string representation of at least a specified
    number of characters.
    ÚminSizeÚreturnNc                 ó<   — t         j                  | «       || _        y ©N)Ú	ExceptionÚ__init__r   )Úselfr   s     r   r   zLargeError.__init__!   s   € Ü×Ñ˜4Ô Øˆ�r   c                 ó,   — d| j                   z  }d|› d�S )NÚxzLargeError<I fail: ú>)r   )r   Úlarges     r   Ú__str__zLargeError.__str__%   s   € Ø�d—l‘lÑ"ˆØ$ U G¨1Ð-Ð-r   )r   r   r   Ú__doc__Úintr   r!   r   r   r   r   r      s   „ ñð
 ð ¨ó ó.r   r   c                   ó   — e Zd Zd„ Zd„ Zy)ÚFailureInSetUpMixinc                 ó   — t        d«      ‚)NzI am a broken setUp method©r   ©r   s    r   ÚsetUpzFailureInSetUpMixin.setUp+   s   € ÜÐ7Ó8Ð8r   c                  ó   — y r   r   r(   s    r   Ú	test_noopzFailureInSetUpMixin.test_noop.   ó   € Ør   N)r   r   r   r)   r+   r   r   r   r%   r%   *   s   „ ò9ór   r%   c                   ó   — e Zd Zy)ÚSynchronousTestFailureInSetUpNr   r   r   r   r.   r.   2   r   r   r.   c                   ó   — e Zd Zy)ÚAsynchronousTestFailureInSetUpNr   r   r   r   r0   r0   6   r   r   r0   c                   ó   — e Zd Zd„ Zd„ Zy)ÚFailureInTearDownMixinc                 ó   — t        d«      ‚)NzI am a broken tearDown methodr'   r(   s    r   ÚtearDownzFailureInTearDownMixin.tearDown;   s   € ÜÐ:Ó;Ð;r   c                  ó   — y r   r   r(   s    r   r+   z FailureInTearDownMixin.test_noop>   r,   r   N)r   r   r   r4   r+   r   r   r   r2   r2   :   s   „ ò<ór   r2   c                   ó   — e Zd Zy)Ú SynchronousTestFailureInTearDownNr   r   r   r   r7   r7   B   ó   „ ð 	r   r7   c                   ó   — e Zd Zy)Ú!AsynchronousTestFailureInTearDownNr   r   r   r   r:   r:   H   r   r   r:   c                   ó    — e Zd ZdZdZd„ Zd„ Zy)ÚFailureButTearDownRunsMixinz7
    A test fails, but its L{tearDown} still runs.
    Fc                 ó   — d| _         y ©NT)ÚtornDownr(   s    r   r4   z$FailureButTearDownRunsMixin.tearDownS   s	   € Øˆ�r   c                 ó   — t        d«      ‚)z$
        A test that fails.
        zI am a broken testr'   r(   s    r   Ú
test_failsz&FailureButTearDownRunsMixin.test_failsV   s   € ô Ð/Ó0Ð0r   N)r   r   r   r"   r?   r4   rA   r   r   r   r<   r<   L   s   „ ñð €Hòó1r   r<   c                   ó   — e Zd Zy)Ú%SynchronousTestFailureButTearDownRunsNr   r   r   r   rC   rC   ]   r8   r   rC   c                   ó   — e Zd Zy)Ú&AsynchronousTestFailureButTearDownRunsNr   r   r   r   rE   rE   c   r8   r   rE   c                   ó   — e Zd Zd„ Zd„ Zd„ Zy)ÚTestRegularFailc                 ó&   — | j                  d«       y )NúI fail©Úfailr(   s    r   Ú	test_failzTestRegularFail.test_failj   s   € Ø�	‰	�(Õr   c                 ó$   — | j                  «        y r   )Ú
subroutiner(   s    r   Útest_subfailzTestRegularFail.test_subfailm   s   € Ø�‰Õr   c                 ó&   — | j                  d«       y )NzI fail insiderJ   r(   s    r   rN   zTestRegularFail.subroutinep   s   € Ø�	‰	�/Õ"r   N)r   r   r   rL   rO   rN   r   r   r   rG   rG   i   s   „ òòó#r   rG   c                   óx   — e Zd ZdZdZdej                  d   fd„Zdej                  d   fd„Zd
d„Z	d
d„Z
d
d	„Zy)ÚTestAsynchronousFailz?
    Test failures for L{unittest.TestCase} based classes.
    rI   r   Nc                 ó:   — t        t        d| j                  d«      S )zW
        A test which fails in the callback of the returned L{defer.Deferred}.
        r   zI fail later©r   r   rK   r(   s    r   rL   zTestAsynchronousFail.test_fail{   s   € ô œ' 1 d§i¡i°Ó@Ð@r   c                 óF   — t        t        d| j                  dddz  z   «      S )zw
        A test which fails in the callback of the returned L{defer.Deferred}
        with a very long string.
        r   zI fail later: r   é   rT   r(   s    r   Útest_failGreaterThan64kz,TestAsynchronousFail.test_failGreaterThan64k�   s#   € ô
 œ' 1 d§i¡iÐ1AÀCÈ%ÁKÑ1OÓPÐPr   c                 ó,   — t        | j                  «      ‚)zA
        A test which raises an exception synchronously.
        )r   Útextr(   s    r   Útest_exceptionz#TestAsynchronousFail.test_exceptionˆ   s   € ô ˜Ÿ	™	Ó"Ð"r   c                 ó   — t        d«      ‚)zk
        A test which raises an exception with a long string representation
        synchronously.
        rV   )r   r(   s    r   Útest_exceptionGreaterThan64kz1TestAsynchronousFail.test_exceptionGreaterThan64kŽ   s   € ô
 ˜ÓÐr   c                 ó   — t        ddz  «      ‚)z‡
        A test which synchronously raises an exception with a long string
        representation including non-ascii content.
        u   â˜ƒi €  )r   r(   s    r   Ú#test_exceptionGreaterThan64kEncodedz8TestAsynchronousFail.test_exceptionGreaterThan64kEncoded•   s   € ô ˜¨Ñ-Ó.Ð.r   )r   N)r   r   r   r"   rY   r   ÚDeferredrL   rW   rZ   r\   r^   r   r   r   rR   rR   t   sK   „ ñð €DðA˜5Ÿ>™>¨$Ñ/ó AðQ¨¯©¸Ñ)=ó Qó#ó ô	/r   rR   c                   ó   — e Zd ZdZdZd„ Zy)Ú	ErrorTestz�
    A test case which has a L{test_foo} which will raise an error.

    @ivar ran: boolean indicating whether L{test_foo} has been run.
    Fc                 ó   — d| _         ddz   y)zJ
        Set C{self.ran} to True and raise a C{ZeroDivisionError}
        Té   r   N)Úranr(   s    r   Útest_foozErrorTest.test_fooª   s   € ð ˆŒØ	ˆA‹r   N)r   r   r   r"   rd   re   r   r   r   ra   ra   ¡   s   „ ñð €Cór   ra   Tzskipping this testc                   ó   — e Zd Zy)ÚTestSkipTestCaseNr   r   r   r   rg   rg   ²   s   „ àr   rg   c                   óP   — e Zd ZdZd„ Zd„ Z ej                  de¬«      ge_        y)ÚDelayedCallzsomething blew upc                 ó,   — t        | j                  «      ‚r   )ÚRuntimeErrorÚhiddenExceptionMsgr(   s    r   ÚgozDelayedCall.goº   s   € Ü˜4×2Ñ2Ó3Ð3r   c                 ó�   — t        j                  d| j                  «       t        j                  d«       | j	                  d«       y)a®  
        What happens if an error is raised in a DelayedCall and an error is
        also raised in the test?

        L{test_reporter.ErrorReportingTests.testHiddenException} checks that
        both errors get reported.

        Note that this behaviour is deprecated. A B{real} test would return a
        Deferred that got triggered by the callLater. This would guarantee the
        delayed call error gets reported.
        r   g{®Gáz„?z/Deliberate failure to mask the hidden exceptionN)r   Ú	callLaterrm   ÚiteraterK   r(   s    r   ÚtestHiddenExceptionzDelayedCall.testHiddenException½   s1   € ô 	×Ñ˜!˜TŸW™WÔ%Ü�‰˜ÔØ�	‰	ÐCÕDr   z!reactor\.iterate cannot be used.*)ÚmessageÚcategoryN)	r   r   r   rl   rm   rq   r	   ÚsuppressÚDeprecationWarningr   r   r   ri   ri   ·   s4   „ Ø,Ðò4òEð" 	ˆ�‰Ø8ÐCUô	
ð$ÐÕ r   ri   c                   ó   — e Zd Zd„ Zy)ÚReactorCleanupTestsc                 ó6   — d„ }t        j                  d|«       y )Nc                  ó   — t        d«       y )Nzfoo!)Úprintr   r   r   Ú_z8ReactorCleanupTests.test_leftoverPendingCalls.<locals>._Ö   s	   € Ü�&�Mr   g     ˆÃ@)r   ro   )r   r{   s     r   Útest_leftoverPendingCallsz-ReactorCleanupTests.test_leftoverPendingCallsÕ   s   € ò	ô 	×Ñ˜' 1Õ%r   N)r   r   r   r|   r   r   r   rw   rw   Ô   s   „ ó&r   rw   c                   ó   — e Zd Zd„ Zy)ÚSocketOpenTestc                 ó‚   — t        j                  «       }t         j                  |_         t        j                  d|«       y )Nr   )r   ÚFactoryÚProtocolr   Ú	listenTCP)r   Úfs     r   Útest_socketsLeftOpenz#SocketOpenTest.test_socketsLeftOpenÝ   s-   € Ü×ÑÓˆÜ×&Ñ&ˆŒ
Ü×Ñ˜!˜QÕr   N)r   r   r   r„   r   r   r   r~   r~   Ü   s   „ ó r   r~   c                   ó   — e Zd Zd„ Zd„ Zd„ Zy)ÚTimingOutDeferredc                  ó   — y r   r   r(   s    r   Ú
test_alphazTimingOutDeferred.test_alphaä   r,   r   c                 ó<   — d| _         t        j                  «       }|S r>   )ÚmethodCalledr   r_   )r   Úds     r   Útest_deferredThatNeverFiresz-TimingOutDeferred.test_deferredThatNeverFiresç   s   € Ø ˆÔÜ�N‰NÓˆØˆr   c                  ó   — y r   r   r(   s    r   Ú
test_omegazTimingOutDeferred.test_omegaì   r,   r   N)r   r   r   rˆ   rŒ   rŽ   r   r   r   r†   r†   ã   s   „ òòó
r   r†   c                  ó   — y)zci will raise an unexpected exception...
    ... *CAUSE THAT'S THE KINDA GUY I AM*

    >>> 1/0
    Nr   r(   s    r   ÚunexpectedExceptionr�   ð   s   � r   c                   ó&   — e Zd ZU dZdZeed<   d„ Zy)ÚEventuallyFailingTestCasez>
    A test suite that fails after it is run a few times.
    r   Únc                 óp   — | xj                   dz  c_         | j                   dk\  r| j                  d«       yy)zK
        Run successfully a few times and then fail forever after.
        rc   é   zeventually failingN)r“   rK   r(   s    r   Útest_itz!EventuallyFailingTestCase.test_itÿ   s.   € ð 	�Š�!‰�Ø�6‰6�QŠ;Ø�I‰IÐ*Õ+ð r   N)r   r   r   r"   r“   r#   Ú__annotations__r–   r   r   r   r’   r’   ø   s   … ñð €A€sƒJó,r   r’   N)#r"   r   r   Útwisted.internetr   r   r   Útwisted.internet.taskr   Útwisted.trialr	   r   r   r   r%   ÚSynchronousTestCaser.   ÚTestCaser0   r2   r7   r:   r<   rC   rE   rG   rR   ra   rg   ri   rw   r~   r†   r�   r’   r   r   r   ú<module>r�      sŽ  ðñ
õ ç 5Ñ 5Ý ,ß (ô	�9ô 	ô.�ô .÷ñ ô	Ð$7¸×9UÑ9Uô 	ô	Ð%8¸(×:KÑ:Kô 	÷ñ ô	Ø˜H×8Ñ8ô	ô	Ð(>À×@QÑ@Qô 	÷1ñ 1ô"	Ø ×!=Ñ!=ô	ô	Ø ×!2Ñ!2ô	ô#�h×2Ñ2ô #ô*/˜8×,Ñ,ô */ôZ�×,Ñ,ô ñ" ˆÐ"Ó#ô	�x×3Ñ3ó 	ó $ð	ô�(×#Ñ#ô ô:&˜(×+Ñ+ô &ô �X×&Ñ&ô  ô
˜×)Ñ)ô 
òô, × <Ñ <õ ,r   