
    h                     L   S r SSKJr  SSKJrJrJr  SSKJr  SSK	JrJ
r
   " S S\5      r " S S	\5      r " S
 S5      r " S S\\R                  5      r " S S\\R"                  5      r " S S5      r " S S\\R                  5      r " S S\\R"                  5      r " S S5      r " S S\\R                  5      r " S S\\R"                  5      r " S S\R                  5      r " S S\R"                  5      r " S  S!\R                  5      r\" S"S#5       " S$ S%\R                  5      5       r " S& S'\R"                  5      r " S( S)\R"                  5      r " S* S+\R"                  5      r " S, S-\R"                  5      r S. r! " S/ S0\R                  5      r"g1)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                       \ rS rSrSrg)FoolishError    N__name__
__module____qualname____firstlineno____static_attributes__r       c/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/trial/test/erroneous.pyr   r          r   r   c                   0    \ rS rSrSrS\SS4S jrS rSrg)	
LargeError   z^
An exception which has a string representation of at least a specified
number of characters.
minSizereturnNc                 :    [         R                  U 5        Xl        g N)	Exception__init__r   )selfr   s     r   r   LargeError.__init__!   s    4 r   c                 ,    SU R                   -  nSU S3$ )NxzLargeError<I fail: >r   )r    larges     r   __str__LargeError.__str__%   s    dll"$UG1--r   r%   )	r   r   r   r   __doc__intr   r'   r   r   r   r   r   r      s    
  .r   r   c                        \ rS rSrS rS rSrg)FailureInSetUpMixin*   c                     [        S5      e)NzI am a broken setUp methodr   r    s    r   setUpFailureInSetUpMixin.setUp+   s    788r   c                     g r   r   r0   s    r   	test_noopFailureInSetUpMixin.test_noop.       r   r   N)r   r   r   r   r1   r4   r   r   r   r   r,   r,   *   s    9r   r,   c                       \ rS rSrSrg)SynchronousTestFailureInSetUp2   r   Nr   r   r   r   r8   r8   2   r   r   r8   c                       \ rS rSrSrg)AsynchronousTestFailureInSetUp6   r   Nr   r   r   r   r;   r;   6   r   r   r;   c                        \ rS rSrS rS rSrg)FailureInTearDownMixin:   c                     [        S5      e)NzI am a broken tearDown methodr/   r0   s    r   tearDownFailureInTearDownMixin.tearDown;   s    :;;r   c                     g r   r   r0   s    r   r4    FailureInTearDownMixin.test_noop>   r6   r   r   N)r   r   r   r   rA   r4   r   r   r   r   r>   r>   :   s    <r   r>   c                       \ rS rSrSrg) SynchronousTestFailureInTearDownB   r   Nr   r   r   r   rF   rF   B        	r   rF   c                       \ rS rSrSrg)!AsynchronousTestFailureInTearDownH   r   Nr   r   r   r   rJ   rJ   H   r   r   rJ   c                   (    \ rS rSrSrSrS rS rSrg)FailureButTearDownRunsMixinL   z/
A test fails, but its L{tearDown} still runs.
Fc                     SU l         g NTtornDownr0   s    r   rA   $FailureButTearDownRunsMixin.tearDownS   s	    r   c                     [        S5      e)z
A test that fails.
zI am a broken testr/   r0   s    r   
test_fails&FailureButTearDownRunsMixin.test_failsV   s     /00r   rQ   N)	r   r   r   r   r)   rR   rA   rU   r   r   r   r   rM   rM   L   s     H1r   rM   c                       \ rS rSrSrg)%SynchronousTestFailureButTearDownRuns]   r   Nr   r   r   r   rX   rX   ]   rH   r   rX   c                       \ rS rSrSrg)&AsynchronousTestFailureButTearDownRunsc   r   Nr   r   r   r   r[   r[   c   rH   r   r[   c                   &    \ rS rSrS rS rS rSrg)TestRegularFaili   c                 &    U R                  S5        g )NI failfailr0   s    r   	test_failTestRegularFail.test_failj   s    		(r   c                 $    U R                  5         g r   )
subroutiner0   s    r   test_subfailTestRegularFail.test_subfailm   s    r   c                 &    U R                  S5        g )NzI fail insiderb   r0   s    r   rg   TestRegularFail.subroutinep   s    		/"r   r   N)r   r   r   r   rd   rh   rg   r   r   r   r   r^   r^   i   s    #r   r^   c                       \ rS rSrSrSrS\R                  S   4S jrS\R                  S   4S jr	SS jr
SS	 jrSS
 jrSrg)TestAsynchronousFailt   z7
Test failures for L{unittest.TestCase} based classes.
ra   r   Nc                 :    [        [        SU R                  S5      $ )zG
A test which fails in the callback of the returned L{defer.Deferred}.
r   zI fail laterr   r   rc   r0   s    r   rd   TestAsynchronousFail.test_fail{   s     '1dii@@r   c                 F    [        [        SU R                  SSS-  -   5      $ )z_
A test which fails in the callback of the returned L{defer.Deferred}
with a very long string.
r   zI fail later: r#      rp   r0   s    r   test_failGreaterThan64k,TestAsynchronousFail.test_failGreaterThan64k   s#    
 '1dii1AC%K1OPPr   c                 ,    [        U R                  5      e)z1
A test which raises an exception synchronously.
)r   textr0   s    r   test_exception#TestAsynchronousFail.test_exception   s     		""r   c                     [        S5      e)zS
A test which raises an exception with a long string representation
synchronously.
rs   )r   r0   s    r   test_exceptionGreaterThan64k1TestAsynchronousFail.test_exceptionGreaterThan64k   s    
 r   c                     [        SS-  5      e)zo
A test which synchronously raises an exception with a long string
representation including non-ascii content.
u   ☃i   )r   r0   s    r   #test_exceptionGreaterThan64kEncoded8TestAsynchronousFail.test_exceptionGreaterThan64kEncoded   s     -..r   r   )r   N)r   r   r   r   r)   rw   r   Deferredrd   rt   rx   r{   r~   r   r   r   r   rm   rm   t   sK     DA5>>$/ AQ)= Q# 	/r   rm   c                   "    \ rS rSrSrSrS rSrg)	ErrorTest   z
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                     SU l         SS-    g)z:
Set C{self.ran} to True and raise a C{ZeroDivisionError}
T   r   Nranr0   s    r   test_fooErrorTest.test_foo   s     	Ar   r   N)r   r   r   r   r)   r   r   r   r   r   r   r   r      s     Cr   r   Tzskipping this testc                       \ rS rSrSrg)TestSkipTestCase   r   Nr   r   r   r   r   r      s    r   r   c                   R    \ rS rSrSrS rS r\R                  " S\	S9/\l        Sr
g)	DelayedCall   zsomething blew upc                 ,    [        U R                  5      er   )RuntimeErrorhiddenExceptionMsgr0   s    r   goDelayedCall.go   s    42233r   c                     [         R                  " SU R                  5        [         R                  " S5        U R	                  S5        g)an  
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{Gz?z/Deliberate failure to mask the hidden exceptionN)r   	callLaterr   iteraterc   r0   s    r   testHiddenExceptionDelayedCall.testHiddenException   s1     	!TWW%		CDr   z!reactor\.iterate cannot be used.*)messagecategoryr   N)r   r   r   r   r   r   r   r	   suppressDeprecationWarningr   r   r   r   r   r      s2    ,4E" 	8CU	
$ r   r   c                       \ rS rSrS rSrg)ReactorCleanupTests   c                 8    S n[         R                  " SU5        g )Nc                      [        S5        g )Nzfoo!)printr   r   r   _8ReactorCleanupTests.test_leftoverPendingCalls.<locals>._   s	    &Mr   g     @)r   r   )r    r   s     r   test_leftoverPendingCalls-ReactorCleanupTests.test_leftoverPendingCalls   s    	 	'1%r   r   N)r   r   r   r   r   r   r   r   r   r   r      s    &r   r   c                       \ rS rSrS rSrg)SocketOpenTest   c                     [         R                  " 5       n[         R                  Ul         [        R                  " SU5        g )Nr   )r   FactoryProtocolr   	listenTCP)r    fs     r   test_socketsLeftOpen#SocketOpenTest.test_socketsLeftOpen   s-    &&
!Qr   r   N)r   r   r   r   r   r   r   r   r   r   r      s     r   r   c                   &    \ rS rSrS rS rS rSrg)TimingOutDeferred   c                     g r   r   r0   s    r   
test_alphaTimingOutDeferred.test_alpha   r6   r   c                 >    SU l         [        R                  " 5       nU$ rP   )methodCalledr   r   )r    ds     r   test_deferredThatNeverFires-TimingOutDeferred.test_deferredThatNeverFires   s     NNr   c                     g r   r   r0   s    r   
test_omegaTimingOutDeferred.test_omega   r6   r   )r   N)r   r   r   r   r   r   r   r   r   r   r   r   r      s    
r   r   c                     g)zWi will raise an unexpected exception...
... *CAUSE THAT'S THE KINDA GUY I AM*

>>> 1/0
Nr   r0   s    r   unexpectedExceptionr      s    r   c                   .    \ rS rSr% SrSr\\S'   S rSr	g)EventuallyFailingTestCase   z6
A test suite that fails after it is run a few times.
r   nc                 r    U =R                   S-  sl         U R                   S:  a  U R                  S5        gg)z;
Run successfully a few times and then fail forever after.
r      zeventually failingN)r   rc   r0   s    r   test_it!EventuallyFailingTestCase.test_it   s.     	!66Q;II*+ r   r   N)
r   r   r   r   r)   r   r*   __annotations__r   r   r   r   r   r   r      s     AsJ,r   r   N)#r)   r   r   twisted.internetr   r   r   twisted.internet.taskr   twisted.trialr	   r   r   r   r,   SynchronousTestCaser8   TestCaser;   r>   rF   rJ   rM   rX   r[   r^   rm   r   r   r   r   r   r   r   r   r   r   r   <module>r      s  
  5 5 , (	9 	. . 	$79U9U 		%8(:K:K 	 	H88		(>@Q@Q 	1 1"	!=!=		!2!2	#h22 #*/8,, */Z,, " "#	x33 	 $	(## :&(++ & X&&  
)) 
, < < ,r   