+
    Dfjc<                       a  0 t $ R t^ RIHt ^ RIt^ RIt^ RIHtHt ^ RI	H
t
 ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHtHt ^ R
IHtHtHt ]! R4      t. tR]R&   ]
! ]P:                  4       ! R R]4      4       tR# )z4
Things likely to be used by writers of unit tests.
)annotationsN)CallableList)implementer)	ParamSpec)deferutils)_T)failure)itrialutil)FailTestSkipTestSynchronousTestCase_Pz
List[None]_wait_is_runningc                     a  ] tR t^!tRtRV 3R lltR R lt]tR tR t	R t
R tR	 tR
 t]P                  R 4       tR tR tR tR tR tR tR V 3R lltR tR t]3R ltRtV ;t# )TestCasea  
A unit test. The atom of the unit testing universe.

This class extends L{SynchronousTestCase} which extends C{unittest.TestCase}
from the standard library. The main feature is the ability to return
C{Deferred}s from tests and fixture methods and to have the suite wait for
those C{Deferred}s to fire.  Also provides new assertions such as
L{assertFailure}.

@ivar timeout: A real number of seconds. If set, the test will
raise an error if it takes longer than C{timeout} seconds.
If not set, util.DEFAULT_TIMEOUT_DURATION is used.
c                L   < \         SV `  V4       ^ RIHp W n        RV n        R# )ag  
Construct an asynchronous test case for C{methodName}.

@param methodName: The name of a method on C{self}. This method should
be a unit test. That is, it should be a short method that calls some of
the assert* methods. If C{methodName} is unspecified,
L{SynchronousTestCase.runTest} will be used as the test method. This is
mostly useful for testing Trial.
reactorFN)super__init__twisted.internetr   _twistedPrivateScheduler_twistedPrivateNeedsTearDown)self
methodNamer   	__class__s   && :/usr/lib/python3/dist-packages/twisted/trial/_asynctest.pyr   TestCase.__init__1   s)     	$ 	- )0% -2)    c               $    V ^8  d   QhRRRRRR/# )   deferredzdefer.Deferred[_T]expectedFailuresztype[BaseException]return )formats   "r   __annotate__TestCase.__annotate__I   s$     / /*/?R/	/r!   c                B   a a V 3R lpVV 3R lpVP                  W44      # )z
Fail if C{deferred} does not errback with one of C{expectedFailures}.
Returns the original Deferred with callbacks added. You will need
to return this Deferred from your test case.
c                .   < SP                  R V : 24      h)z$did not catch an error, instead got )failureException)ignorer   s   &r   _cb#TestCase.assertFailure.<locals>._cbR   s     ''6vjA r!   c                   < V P                   ! S!  '       d   V P                  # R P                  S\        V 4      4      pSP	                  V4      h)z
Expected: {!r}
Got:
{})checkvaluer(   strr-   )r
   outputr%   r   s   & r   _eb#TestCase.assertFailure.<locals>._ebW   sI    }}.//}}$5<<$c'l ++F33r!   )addCallbacks)r   r$   r%   r/   r6   s   f&j  r   assertFailureTestCase.assertFailureI   s     	
	4 $$S..r!   c                	  a aaaa S P                  4       oVVV V3R  lp\        P                  ! V\        P                  ! \
        R7      4      p\        P                  ! V4      '       d1   \        RP                  V4      4      p\        P                  ! V4      # \        P                  ! \        P                  S P                  4       V4      pS P                  P!                  SWF4      oVP#                  V3R l4       V# )c                  < \         P                  ! S: R S RS R24      p\        P                  ! V4      p V P	                  V4       R#   \         P
                   dx    SP                  P                  4        RSn        SP                  4       pTe-   TP                  T4      '       d   SP                  SY#4        R# SP                  ST4        R# i ; i)z (z) still running at z secsTN)r   TimeoutErrorr
   FailureerrbackAlreadyCalledErrorr   crash	_timedOutgetTodoexpectedaddExpectedFailureaddError)deftodofuncDescriptionresultr   timeouts   &   r   	onTimeout TestCase._run.<locals>.onTimeoutg   s    ""("_--@	OA "A-		!++ 
- --335!%||~#a(8(8--dA<OOD!,
-s   A A C-CCCcategoryz9{!r} is a generator function and therefore will never runc                h   < SP                  4       ;'       d    SP                  4       ;'       g    T # N)activecancel)xcalls   &r   <lambda>TestCase._run.<locals>.<lambda>   s$    DKKM;;dkkm@@q@r!   )
getTimeoutr   suppressWarningsr   suppressDeprecationWarninginspectisgeneratorfunction	TypeErrorr(   r   failmaybeDeferredrunWithWarningsSuppressed_getSuppressr   	callLateraddBoth)	r   funcrK   rL   rN   excrG   rW   rM   s	   f&ff   @@r   _runTestCase._rund   s    //#	- 	-, **t}}.@A
	 &&t,,KRRSWXC ::c?"++T->->-@$
 ,,66w	M			@Ar!   c                	&    V P                   ! V/ VB # rS   )run)r   argskwargss   &*,r   __call__TestCase.__call__   s    xx(((r!   c                	  "     V P                  V4      G R j  xL
  V P                  V4      G R j  xL
   V P                  '       d   V P                  V4      G R j  xL
  R # R #  LM L6  T P                  T4      G R j  xL 
  i ; i L+  T P                  '       d   T P                  T4      G R j  xL 
  i i ; i5irS   )_deferSetUpAndRun_deferRunCleanupsr   _deferTearDownr   rL   s   &&r   _deferSetUpTestCase._deferSetUp   s     	25,,V444,,V444000))&111 1	 54d,,V444 2 000))&111 1s|   B>A+ A'A+ B A)B B>
B>B
B>'A+ )B +B BBB 
B>'B;3B64B;;B>c                \  "    V P                  V P                  RV4      G Rj  xL
  RT n         T P                  \        Y P                  4      T P                  T4      G Rj  xL
  T P                  4       e"   TP                  Y P                  4       4       R# RT n        R#  L  \         d7   pTP                  Y P	                  T P                  T4      4        Rp?R# Rp?i\
         dB   pTP                  T \        P                  ! T4      4       TP                  4         Rp?R# Rp?i\         d2   pTP                  T \        P                  ! T4      4        Rp?R# Rp?ii ; i EL  \         d-   pT P#                  \        P                  ! T4      T4       h Rp?ii ; i5i)zS
Execute the setUp and run part of a test. Teardown and cleanups are not executed.
setUpNT)ri   ry   r   addSkip_getSkipReasonKeyboardInterruptrF   r
   r>   stopBaseExceptionr   getattr_testMethodNamerC   addUnexpectedSuccess_passed_ebDeferTestMethodr   rL   rH   s   && r   rr   TestCase._deferSetUpAndRun   s@    	))DJJ888 -1)
	))223T5I5I6   ||~)++D,,.A#+ 9 	NN4!4!4TZZ!CD  	OOD'//!"45KKM 	OOD'//!"45	  	##GOOA$6?	s   F, B' B%B' F,3E2 $E/%5E2 F,E2 #F,%B' 'E,2+C#F,#E,0E,16D-'F,-E,:E,;&E'!F,'E,,F,/E2 2F)='F$$F))F,c           	     	J   V P                  4       pVe,   VP                  V4      '       d   VP                  WV4       R # VP                  V P                  \
        4      '       d   VP                  W4       R # VP                  \        4      '       d$   VP                  W4       VP                  4        R # VP                  \        4      '       dA   VP                  W P                  \        W P                  4      VP                  4      4       R # VP                  W4       R # rS   )rC   rD   rE   r2   r-   r   
addFailurer|   rF   r}   r   rz   r{   r   r   r3   )r   rI   rL   rJ   s   &&& r   r   TestCase._ebDeferTestMethod   s    ||~a 0 0%%dt4WWT**H55d&WW&''OOD$KKMWWXNN))'$8L8L*MqwwW OOD$r!   c                	  "    V P                  V P                  R V4      G Rj  xL
  R#  L  \         dI   pTP                  T \        P
                  ! T4      4       TP                  4        RT n         Rp?R# Rp?i\         d9   pTP                  T \        P
                  ! T4      4       RT n         Rp?R# Rp?ii ; i5i)tearDownNF)	ri   r   r|   rF   r
   r>   r}   r   r~   r   s   && r   rt   TestCase._deferTearDown   s     	!))DMM:v>>>  	!OOD'//!"45KKM DLL 	!OOD'//!"45 DLL	!sN   C - +- C- C=A;5C;CC	-B<6C<CCc              #    aaa"   . p\        V P                  4      ^ 8  dJ   V P                  P                  4       w  ooo V P                  VVV3R lRSP                   2V4      x  Kc  V F  pVP                  W4       RV n
        K  	  R#   \
         d)    TP                  \        P                  ! 4       4        K  i ; i5i)zN
Run any scheduled cleanups and report errors (if any) to the result.
object.
c                    < S! S / SB # rS   r'   )rm   rg   rn   s   r   rX   ,TestCase._deferRunCleanups.<locals>.<lambda>   s    D$1&1r!   zcleanup function FN)len	_cleanupspopri   __name__	Exceptionappendr
   r>   rF   r   )r   rL   failuresrI   rm   rg   rn   s   &&  @@@r   rs   TestCase._deferRunCleanups   s      $..!A%!%!3!3!5D$3ii1'7  AOOD$ DL   3 123s)   ;C(B )%C/C=C CCc                	    \         P                  ! W4      P                  4       pV'       g   R V n        T P                  P                  4        F  pTP                  Y4       R T n        K  	  T P                  4        T P                  4        T P                  '       d   TP                  T 4       R# R#   \         d0    TP                  T \        P                  ! 4       4       R T n         Li ; i)FN)r   _JanitorpostCaseCleanupr   r~   rF   r
   r>   	_observer	getErrorsflushLoggedErrors_removeObserver
addSuccess)r   rL   cleanerrors   &&  r   _cleanUpTestCase._cleanUp   s    	!MM$/??AE$ ^^--/EOOD( DL 0 	 <<<d#   	!OOD'//"34 DL	!s   3B5 57C/.C/c                	     \         P                  ! W4      P                  4        R #   \         d*    TP	                  T \
        P                  ! 4       4        R # i ; irS   )r   r   postClassCleanupr~   rF   r
   r>   ru   s   &&r   _classCleanUpTestCase._classCleanUp   s@    	5MM$'88: 	5OOD'//"34	5s   $( 0AAc                   a a VV 3R lpV# )z}
Create a method which wraps the reactor method C{name}. The new
method issues a deprecation warning and calls the original.
c                    < \         P                  ! R S: RS: R2^\        R7       SP                  S,          ! V / VB # )zreactor.z8 cannot be used inside unit tests. In the future, using z7 will fail the test and may crash or hang the test run.)
stacklevelrQ   )warningswarnr]   _reactorMethods)akwnamer   s   *,r   _&TestCase._makeReactorMethod.<locals>._  s@    MM 26t= + ''-q7B77r!   r'   )r   r   r   s   ff r   _makeReactorMethodTestCase._makeReactorMethod   s    	8 r!   c                    / V n         R F6  p\        W4      V P                   V&   \        WV P                  V4      4       K8  	  R# )z
Deprecate C{iterate}, C{crash} and C{stop} on C{reactor}. That is,
each method is wrapped in a function that issues a deprecation
warning, then calls the original.

@param reactor: The Twisted reactor.
N)rA   iterater}   )r   r   setattrr   )r   r   r   s   && r   _deprecateReactorTestCase._deprecateReactor  s@      "0D)0)?D  &G4#:#:4#@A 1r!   c                r    V P                   P                  4        F  w  r#\        WV4       K  	  / V n         R# )zu
Restore the deprecated reactor methods. Undoes what
L{_deprecateReactor} did.

@param reactor: The Twisted reactor.
N)r   itemsr   )r   r   r   methods   &&  r   _undeprecateReactorTestCase._undeprecateReactor  s1     !00668LDG6* 9!r!   c                   ^ RI Hp V P                  V4       RV n         \        P
                  P                  V P                  V4      4      p V P                  V4       V P                  V4       V P                  V4        V P                  V4       R#   T P                  T4       T P                  T4       i ; i  T P                  T4       i ; i)z
Really run C{setUp}, the test method, and C{tearDown}.  Any of these may
return L{defer.Deferred}s. After they complete, do some reactor cleanup.

@param result: A L{TestResult} object.
r   FN)r   r   r   rB   r   DeferredfromCoroutinerv   _waitr   r   r   )r   rL   r   rG   s   &&  r   _runFixturesAndTestTestCase._runFixturesAndTest)  s     	-w'	.,,T-=-=f-EFA+

1f%""6*$$W- f%""6*$$W-s#   .B= B  "B= $B::B= =Cc               (    V ^8  d   QhRRRRRRRR/# )	r#   rI   zCallable[_P, object]rm   z_P.argsrn   z	_P.kwargsr&   Noner'   )r(   s   "r   r)   r*   @  s,     6 6%6.56AJ6	6r!   c                ,   < \         SV `  ! V.VO5/ VB # )a:  
Extend the base cleanup feature with support for cleanup functions which
return Deferreds.

If the function C{f} returns a Deferred, C{TestCase} will wait until the
Deferred has fired before proceeding to the next function.

If the function takes more than C{timeout} settings, then the test will
raise an error.
)r   
addCleanup)r   rI   rm   rn   r   s   &&*,r   r   TestCase.addCleanup@  s     w!!5d5f55r!   c                	"    V P                  4       # rS   )rd   )r   s   &r   getSuppressTestCase.getSuppressO  s      ""r!   c                    \         P                  ! V P                  R\         P                  4      p \	        V4      #   \
        \        3 d0    \        P                  ! R\        R7       \         P                  u # i ; i)a5  
Returns the timeout value set on this test. Checks on the instance
first, then the class, then the module, then packages. As soon as it
finds something with a C{timeout} attribute, returns that. Returns
L{util.DEFAULT_TIMEOUT_DURATION} if it cannot find anything. See
L{TestCase} docstring for more details.
rM   z)'timeout' attribute needs to be a number.rP   )
r   acquireAttribute_parentsDEFAULT_TIMEOUT_DURATIONfloat
ValueErrorr`   r   r   r]   )r   rM   s   & r   rZ   TestCase.getTimeoutR  sj     ''MM9d&C&C

	1>!I& 	1
 MM;FX 000	1s   
= =A=<A=c                  aa V'       d   \        R4      h^ RIHo . oV3R lpVV3R lp\        P                  ! V\
        P                  ! R\        R7      4      pV3R lp\        P                  ! V\
        P                  ! R\        R7      4      pVP                  R4        VP                  V4       S'       d    RoVP                  4        R# VP                  V4       VSn         SP                  4        S=S'       g   V P                  '       d    RoVP                  4        R# \        4       h  S=i ; i  RoTP                  4        i ; i)	zATake a Deferred that only ever callbacks. Block until it happens.z_wait is not reentrantr   c                6   < Se   SP                  V 4       R # R # rS   )r   )anyresultss   &r   r   TestCase._wait.<locals>.appendr  s    "s# #r!   c                4   < Se   SP                  4        R # R # rS   rA   )ignr   r   s   &r   rA   TestCase._wait.<locals>.crashv  s    " #r!   zreactor\.crash cannot be used.*)messagerQ   c                 (   < S P                  4        R # rS   r   r   s   r   r}   TestCase._wait.<locals>.stop  s    MMOr!   N)RuntimeErrorr   r   r   r[   r   r\   r]   r   rf   r   r}   rl   rB   r|   )r   rG   runningr   rA   r}   r   r   s   &&&   @@r   r   TestCase._waiti  s   788,	$	  &&MM:EW
	 %%MM:EW
 	t$	IIf < GKKM= IIeGL!L $..." GKKM $%%- L0 GKKMs6   %D> D> ,D7 <	D> D> -
D> 7D;;D> >E)r   r   rB   r   r   )runTest)r   
__module____qualname____firstlineno____doc__r   r9   failUnlessFailureri   ro   rv   rr   r   rt   r   inlineCallbacksrs   r   r   r   r   r   r   r   r   rZ   r   r   __static_attributes____classcell__)r   s   @r   r   r   !   s    20/2 &&P)2>% 	! ! !*$ 5$B	"..6 6#1.  0 G Gr!   r   )__conditional_annotations__r   
__future__r   r^   r   typingr   r   zope.interfacer   r   r   r   r   twisted.internet.deferr	   twisted.pythonr
   twisted.trialr   r   twisted.trial._synctestr   r   r   r   r   __annotations__	ITestCaser   )r   s   @r   <module>r      sq   
 #   ! & 
 * % " & K Kt_! * ! VN" N Nr!   