+
    DfjV                       R t ^ RIHt ^ RIt^ RIt^ RIt^ RI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 ^ R
IHt ^ RIHt ^ RIHt ^ RIHtHtHtHtH t   ! R R]4      t! ! R R]4      t" ! R R4      t# ! R R4      t$ ! R R]4      t% ! R R]4      t& ! R R]4      t' ! R R]4      t( ! R R]4      t) ! R  R!]4      t*R# )"z!
Tests for L{twisted.trial.util}
)annotationsN)StringIO)	Generator)implementer)assert_thatequal_to)DelayedCall)IProcessTransport)filepath)Failure)util)SynchronousTestCase)DirtyReactorAggregateError_JanitoracquireAttributeexcInfoOrFailureToExcInfoopenTestLogc                  J    ] tR t^#tRtR R ltR R ltR R ltR R	 ltR
t	R# )MktempTestsza
Tests for L{TestCase.mktemp}, a helper function for creating temporary file
or directory names.
c                   V ^8  d   QhRR/#    returnNone )formats   ">/usr/lib/python3/dist-packages/twisted/trial/test/test_util.py__annotate__MktempTests.__annotate__)   s     	
 	
4 	
    c                    V P                  4       p\        P                  P                  V4      P	                  \        P
                  4      RR pV P                  V. RO4       R# )z~
The path name returned by C{mktemp} is directly beneath a directory
which identifies the test method which created the name.
N)ztwisted.trial.test.test_utilr   	test_name)mktempospathdirnamesplitsepassertEqual)selfnamedirss   &  r   r"   MktempTests.test_name)   sK    
 {{}wwt$**26623B7N	
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   4   s     1 1T 1r   c                d    V P                  4       pV P                  WP                  4       4       R# )z6
Repeated calls to C{mktemp} return different values.
N)r#   assertNotEqual)r*   r+   s   & r   test_uniqueMktempTests.test_unique4   s#     {{}D++-0r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   ;   s     / /d /r   c                   V P                  4       p\        P                  P                  V4      pV P	                  \        P                  P                  V4      4       V P                  \        P                  P                  V4      4       R# )zC
The directory part of the path name returned by C{mktemp} exists.
N)r#   r$   r%   r&   
assertTrueexistsassertFalse)r*   r+   r&   s   &  r   test_createdMktempTests.test_created;   sU     {{}''//$'w/0-.r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   D   s     6 6t 6r   c                    \         P                  P                  V P                  4       4      pV P	                  VP                  \         P                  ! 4       4      4       R# )zJ
The path returned by C{mktemp} is beneath the current working directory.
N)r$   r%   abspathr#   r5   
startswithgetcwd)r*   r%   s   & r   test_locationMktempTests.test_locationD   s7     wwt{{}-		45r   r   N)
__name__
__module____qualname____firstlineno____doc__r"   r1   r8   r?   __static_attributes__r   r   r   r   r   #   s     
	
1/6 6r   r   c                  >    ] tR t^LtRtR R ltR R ltR R ltRtR	# )
DirtyReactorAggregateErrorTestsz.
Tests for the L{DirtyReactorAggregateError}.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ,DirtyReactorAggregateErrorTests.__annotate__Q        
 
 
r   c                V    \        RR.4      pV P                  \        V4      R4       R# )z%
Delayed calls are formatted nicely.
FoobarzhReactor was unclean.
DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)
Foo
barNr   r)   strr*   errors   & r   test_formatDelayedCall6DirtyReactorAggregateErrorTests.test_formatDelayedCallQ   s,     +E5>:J	
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   rJ   _   rK   r   c                X    \        . RR.4      pV P                  \        V4      R4       R# )z#
Selectables are formatted nicely.
zselectable 1zselectable 2z;Reactor was unclean.
Selectables:
selectable 1
selectable 2NrO   rQ   s   & r   test_formatSelectables6DirtyReactorAggregateErrorTests.test_formatSelectables_   s/     +2/OPJ	
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   rJ   m   s     
 
t 
r   c                \    \        RR.RR.4      pV P                  \        V4      R4       R# )zB
Both delayed calls and selectables can appear in the same error.
bleckBoozoSel1Sel2zReactor was unclean.
DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)
bleck
Boozo
Selectables:
Sel1
Sel2NrO   rQ   s   & r   %test_formatDelayedCallsAndSelectablesEDirtyReactorAggregateErrorTests.test_formatDelayedCallsAndSelectablesm   s4     +GW+=?OPJ
	
r   r   N)	rA   rB   rC   rD   rE   rS   rW   r_   rF   r   r   r   rH   rH   L   s    


 
r   rH   c                  R    ] tR t^tRtRR R lltRR R lltR R ltR	 R
 ltRt	R# )StubReactorab  
A reactor stub which contains enough functionality to be used with the
L{_Janitor}.

@ivar iterations: A list of the arguments passed to L{iterate}.
@ivar removeAllCalled: Number of times that L{removeAll} was called.
@ivar selectables: The value that will be returned from L{removeAll}.
@ivar delayedCalls: The value to return from L{getDelayedCalls}.
Nc               $    V ^8  d   QhRRRRRR/# )r   delayedCallslist[DelayedCall]selectableszlist[object] | Noner   r   r   )r   s   "r   r   StubReactor.__annotate__   s$     ' '-'<O'	'r   c                N    Wn         . V n        ^ V n        V'       g   . pW n        R# )zk
@param delayedCalls: See L{StubReactor.delayedCalls}.
@param selectables: See L{StubReactor.selectables}.
Nrd   
iterationsremoveAllCalledrf   )r*   rd   rf   s   &&&r   __init__StubReactor.__init__   s'     ).0 K&r   c                    V ^8  d   QhRRRR/# )r   timeoutzfloat | Noner   r   r   )r   s   "r   r   rg      s     ( (| (t (r   c                <    V P                   P                  V4       R# )z
Increment C{self.iterations}.
N)rj   append)r*   ro   s   &&r   iterateStubReactor.iterate   s     	w'r   c                   V ^8  d   QhRR/# )r   r   re   r   )r   s   "r   r   rg      s     ! !!2 !r   c                    V P                   # )z
Return C{self.delayedCalls}.
)rd   r*   s   &r   getDelayedCallsStubReactor.getDelayedCalls   s        r   c                   V ^8  d   QhRR/# )r   r   zlist[object]r   )r   s   "r   r   rg      s        <  r   c                L    V ;P                   ^,          un         V P                  # )zC
Increment C{self.removeAllCalled} and return C{self.selectables}.
)rk   rf   rv   s   &r   	removeAllStubReactor.removeAll   s!     	!r   ri   N)
rA   rB   rC   rD   rE   rl   rr   rw   r{   rF   r   r   r   rb   rb      s     '(!   r   rb   c                  2    ] tR t^tRtR R ltR R ltRtR# )StubErrorReporterz
A subset of L{twisted.trial.itrial.IReporter} which records L{addError}
calls.

@ivar errors: List of two-tuples of (test, error) which were passed to
    L{addError}.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   StubErrorReporter.__annotate__   s     7 7$ 7r   c                	    . V n         R # r}   errorsrv   s   &r   rl   StubErrorReporter.__init__   s	    46r   c               $    V ^8  d   QhRRRRRR/# )r   testobjectrR   r   r   r   r   )r   s   "r   r   r      s!     * *V *G * *r   c                >    V P                   P                  W34       R# )z&
Record parameters in C{self.errors}.
N)r   rq   )r*   r   rR   s   &&&r   addErrorStubErrorReporter.addError   s     	D=)r   r   N)rA   rB   rC   rD   rE   rl   r   rF   r   r   r   r   r      s    7* *r   r   c                      ] tR t^tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltRtR# )JanitorTestsz
Tests for L{_Janitor}!
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   JanitorTests.__annotate__   s     
5 
5t 
5r   c                    \        . 4      p\        RRVR7      pVP                  4        V P                  VP                  ^ ^ .4       R# )z
During pending-call cleanup, the reactor will be spun twice with an
instant timeout. This is not a requirement, it is only a test for
current behavior. Hopefully Trial will eventually not do this kind of
reactor stuff.
Nreactor)rb   r   _cleanPendingr)   rj   r*   r   jans   &  r   test_cleanPendingSpinsReactor*JanitorTests.test_cleanPendingSpinsReactor   sA     b/tT73++aV4r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     3 3t 3r   c                    R R lp. p\        RVR/ VP                  R 4      p\        V.4      p\        RRVR7      pVP	                  4        V P                  W#.4       R# )zG
During pending-call cleanup, the janitor cancels pending timed calls.
c                   V ^8  d   QhRR/# r   r   rP   r   )r   s   "r   r   @JanitorTests.test_cleanPendingCancelsCalls.<locals>.__annotate__   s     	 	c 	r   c                     R # )Lulzr   r   r   r   func8JanitorTests.test_cleanPendingCancelsCalls.<locals>.func   s    r   ,  c                    R # r}   r   xs   &r   <lambda><JanitorTests.test_cleanPendingCancelsCalls.<locals>.<lambda>   s    QUr   Nr   r   )r   rq   rb   r   r   r)   )r*   r   	cancelleddelayedCallr   r   s   &     r   test_cleanPendingCancelsCalls*JanitorTests.test_cleanPendingCancelsCalls   s^    
	 (*	!#tRY5E5E~V{m,tT73M2r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     7 7D 7r   c           
         \        RR R	/ R R R R7      p\        V4      p\        V.4      p\        RRVR7      pVP	                  4       pV P                  WR.4       R# )
a  
The Janitor produces string representations of delayed calls from the
delayed call cleanup method. It gets the string representations
*before* cancelling the calls; this is important because cancelling the
call removes critical debugging information from the string
representation.
r   c                     R # r}   r   r   r   r   r   IJanitorTests.test_cleanPendingReturnsDelayedCallStrings.<locals>.<lambda>       r   c                    R # r}   r   r   s   &r   r   r          r   c                    R # r}   r   r   s   &r   r   r          r   c                     ^ #     r   r   r   r   r   r          WXr   secondsNr   r   )r   rP   rb   r   r   r)   )r*   r   delayedCallStringr   r   stringss   &     r   *test_cleanPendingReturnsDelayedCallStrings7JanitorTests.test_cleanPendingReturnsDelayedCallStrings   sc     "r2~~y
  ,{m,tT73##%"56r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     5 5T 5r   c                    \        . 4      p\        RRVR7      pVP                  4        V P                  VP                  ^4       R# )z=
The Janitor will remove selectables during reactor cleanup.
Nr   )rb   r   _cleanReactorr)   rk   r   s   &  r   #test_cleanReactorRemovesSelectables0JanitorTests.test_cleanReactorRemovesSelectables   s=     b/tT7300!4r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     / / /r   c                    \        \        4       ! R R4      4       pV! 4       p\        . V.4      p\        RRVR7      pVP	                  4        V P                  VP                  R.4       R# )z9
The Janitor will kill processes during reactor cleanup.
c                  2    ] tR t^tRtR R ltR R ltRtR# )JJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransportzt
A stub L{IProcessTransport} provider which records signals.
@ivar signals: The signals passed to L{signalProcess}.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   WJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransport.__annotate__  s     3 3$ 3r   c                	    . V n         R # r}   signalsrv   s   &r   rl   SJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransport.__init__  s	    02r   c                    V ^8  d   QhRRRR/# )r   signalz	str | intr   r   r   )r   s   "r   r   r     s     , ,I ,$ ,r   c                <    V P                   P                  V4       R# )z&
Append C{signal} to C{self.signals}.
N)r   rq   )r*   r   s   &&r   signalProcessXJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransport.signalProcess  s     ##F+r   r   N)rA   rB   rC   rD   rE   rl   r   rF   r   r   r   StubProcessTransportr      s    
3, ,r   r   Nr   KILL)r   r	   rb   r   r   r)   r   )r*   r   ptr   r   s   &    r   test_cleanReactorKillsProcesses,JanitorTests.test_cleanReactorKillsProcesses   si    
 
&	'	, 	, 
(	, "#b2$'tT73fX.r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     A A4 Ar   c                     ! R R4      p\        . V! 4       .4      p\        RRVR7      pV P                  VP                  4       R.4       R# )zs
The Janitor returns string representations of the selectables that it
cleaned up from the reactor cleanup method.
c                  &    ] tR tRtRtR R ltRtR# )JJanitorTests.test_cleanReactorReturnsSelectableStrings.<locals>.Selectablei  zH
A stub Selectable which only has an interesting string
representation.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   WJanitorTests.test_cleanReactorReturnsSelectableStrings.<locals>.Selectable.__annotate__   s     ' '# 'r   c                	    R # )(SELECTABLE!)r   rv   s   &r   __repr__SJanitorTests.test_cleanReactorReturnsSelectableStrings.<locals>.Selectable.__repr__   s    &r   r   N)rA   rB   rC   rD   rE   r   rF   r   r   r   
Selectabler     s    
' 'r   r   Nr   r   )rb   r   r)   r   )r*   r   r   r   s   &   r   )test_cleanReactorReturnsSelectableStrings6JanitorTests.test_cleanReactorReturnsSelectableStrings  sH    	' 	' b:<.1tT73**,.?@r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   '  s     
. 
.d 
.r   c                    \        . 4      p\        4       p\        4       p\        W#VR7      pV P	                  VP                  4       4       V P                  VP                  . 4       R# )zu
The post-case cleanup method will return True and not call C{addError}
on the result if there are no pending calls.
r   N)rb   r   r   r   r5   postCaseCleanupr)   r   r*   r   r   reporterr   s   &    r   test_postCaseCleanupNoErrors)JanitorTests.test_postCaseCleanupNoErrors'  sQ    
 b/x$&tw7++-."-r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   3  s     X X Xr   c           
        \        RR R	/ R R R R7      p\        V4      p\        V.. 4      p\        4       p\	        4       p\        WEVR7      pV P                  VP                  4       4       V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          ^,          P                  P                  V.4       R# )
z
The post-case cleanup method will return False and call C{addError} on
the result with a L{DirtyReactorAggregateError} Failure if there are
pending calls.
r   c                     R # r}   r   r   r   r   r   =JanitorTests.test_postCaseCleanupWithErrors.<locals>.<lambda>:  r   r   c                    R # r}   r   r   s   &r   r   r   :  r   r   c                    R # r}   r   r   s   &r   r   r   :  r   r   c                     ^ # r   r   r   r   r   r   r   :  r   r   r   r   Nr   )r   rP   rb   r   r   r   r7   r   r)   lenr   valuerd   r*   r   r   r   r   r   r   s   &      r   test_postCaseCleanupWithErrors+JanitorTests.test_postCaseCleanupWithErrors3  s     "r2~~y
  ,{mR0x$&tw7,,./X__-q1+A.44AADUCVWr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   E  s     
. 
.t 
.r   c                    \        . 4      p\        4       p\        4       p\        W#VR7      pVP	                  4        V P                  VP                  . 4       R# )zu
The post-class cleanup method will not call C{addError} on the result
if there are no pending calls or selectables.
r   N)rb   r   r   r   postClassCleanupr)   r   r   s   &    r   test_postClassCleanupNoErrors*JanitorTests.test_postClassCleanupNoErrorsE  sH    
 b/x$&tw7"-r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   Q  s     X XD Xr   c           
        \        RR R	/ R R R R7      p\        V4      p\        V.. 4      p\        4       p\	        4       p\        WEVR7      pVP                  4        V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          ^,          P                  P                  V.4       R# )
z
The post-class cleanup method call C{addError} on the result with a
L{DirtyReactorAggregateError} Failure if there are pending calls.
r   c                     R # r}   r   r   r   r   r   IJanitorTests.test_postClassCleanupWithPendingCallErrors.<locals>.<lambda>W  r   r   c                    R # r}   r   r   s   &r   r   r   W  r   r   c                    R # r}   r   r   s   &r   r   r   W  r   r   c                     ^ # r   r   r   r   r   r   r   W  r   r   r   r   Nr   )r   rP   rb   r   r   r   r   r)   r   r   r   rd   r   s   &      r   *test_postClassCleanupWithPendingCallErrors7JanitorTests.test_postClassCleanupWithPendingCallErrorsQ  s    
 "r2~~y
  ,{mR0x$&tw7X__-q1+A.44AADUCVWr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   b  s     V V4 Vr   c                `   Rp\        . V.4      p\        4       p\        4       p\        W4VR7      pVP	                  4        V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          ^,          P                  P                  \        V4      .4       R# )z
The post-class cleanup method call C{addError} on the result with a
L{DirtyReactorAggregateError} Failure if there are selectables.
zSELECTABLE HEREr   N)rb   r   r   r   r   r)   r   r   r   rf   repr)r*   
selectabler   r   r   r   s   &     r   )test_postClassCleanupWithSelectableErrors6JanitorTests.test_postClassCleanupWithSelectableErrorsb  s    
 '
b:,/x$&tw7X__-q1+A.44@@4
CSBTUr   r   N)rA   rB   rC   rD   rE   r   r   r   r   r   r   r   r   r   r  r	  rF   r   r   r   r   r      sH    
537"5/6A&
.X$
.X"V Vr   r   c                  >    ] tR tRtRtR R ltR R ltR R ltR	tR
# )RemoveSafelyTestsiq  z"
Tests for L{util._removeSafely}.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   RemoveSafelyTests.__annotate__v  s     	L 	L 	Lr   c                    V P                  4       P                  R4      p\        P                  ! V4       \        P
                  ! V4      pV P                  \        P                  \        P                  V4       R# )z
If a path doesn't contain a node named C{"_trial_marker"}, that path is
not removed by L{util._removeSafely} and a L{util._NoTrialMarker}
exception is raised instead.
utf-8N)
r#   encoder$   mkdirr
   FilePathassertRaisesr   _NoTrialMarker_removeSafely)r*   	directorydirPaths   &  r   test_removeSafelyNoTrialMarker0RemoveSafelyTests.test_removeSafelyNoTrialMarkerv  sT     KKM((1	
##I.$--t/A/A7Kr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r    s     C C$ Cr   c                   R R lp\        4       pV P                  \        RV4       V P                  4       P	                  R4      p\
        P                  ! V4       \        P                  ! V4      pVP                  R4      P                  4        Wn        \        P                  ! V4       V P                  RVP                  4       4       R# )z
If an L{OSError} is raised while removing a path in
L{util._removeSafely}, an attempt is made to move the path to a new
name.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   PRemoveSafelyTests.test_removeSafelyRemoveFailsMoveSucceeds.<locals>.__annotate__  s     	 	T 	r   c                     \        4       h)a
Raise an C{OSError} to emulate the branch of L{util._removeSafely}
in which path removal fails.
OSErrorr   r   r   dummyRemoveORemoveSafelyTests.test_removeSafelyRemoveFailsMoveSucceeds.<locals>.dummyRemove  s    
 )Or   stdoutr     _trial_markercould not remove FilePathN)r   patchsysr#   r  r$   r  r
   r  childtouchremover   r  assertIngetvalue)r*   r#  outr  r  s   &    r   (test_removeSafelyRemoveFailsMoveSucceeds:RemoveSafelyTests.test_removeSafelyRemoveFailsMoveSucceeds  s    	 j

3#& KKM((1	
##I.&'--/$7#13<<>Br   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r    s     %C %Ct %Cr   c                   R R lpRR R llp\        4       pV P                  \        RV4       V P                  4       P	                  R4      p\
        P                  ! V4       \        P                  ! V4      pVP                  R4      P                  4        Wn        W%n        V P                  \        \        P                   V4      pV P#                  \%        V4      R4       V P'                  R	VP)                  4       4       R
# )z
If an L{OSError} is raised while removing a path in
L{util._removeSafely}, an attempt is made to move the path to a new
name. If that attempt fails, the L{OSError} is re-raised.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   MRemoveSafelyTests.test_removeSafelyRemoveFailsMoveFails.<locals>.__annotate__  s     	1 	1T 	1r   c                     \        R4      h)r   zpath removal failedr!  r   r   r   r#  LRemoveSafelyTests.test_removeSafelyRemoveFailsMoveFails.<locals>.dummyRemove  s    
 /00r   c               $    V ^8  d   QhRRRRRR/# )r   destinationr   followLinksboolr   r   r   )r   s   "r   r   r5    s!     	2 	2V 	2$ 	2$ 	2r   c                    \        R4      h)zb
Raise an C{OSError} to emulate the branch of L{util._removeSafely}
in which path movement fails.
path movement failedr!  )r9  r:  s   &&r   dummyMoveToLRemoveSafelyTests.test_removeSafelyRemoveFailsMoveFails.<locals>.dummyMoveTo  s    
 011r   r%  r  r&  r=  r'  N)T)r   r(  r)  r#   r  r$   r  r
   r  r*  r+  r,  moveTor  r"  r   r  r)   rP   r-  r.  )r*   r#  r>  r/  r  r  rR   s   &      r   %test_removeSafelyRemoveFailsMoveFails7RemoveSafelyTests.test_removeSafelyRemoveFailsMoveFails  s    	1	2 j

3#& KKM((1	
##I.&'--/ %$!!'4+=+=wGU%;<13<<>Br   r   N)	rA   rB   rC   rD   rE   r  r0  rA  rF   r   r   r   r  r  q  s    	LC:%C %Cr   r  c                  2    ] tR tRtRtR R ltR R ltRtR# )	ExcInfoTestsi  z)
Tests for L{excInfoOrFailureToExcInfo}.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ExcInfoTests.__annotate__  s     A Ad Ar   c                b    \         \        R4      R3pV P                  V\        V4      J 4       R# )z
L{excInfoOrFailureToExcInfo} returns exactly what it is passed, if it is
passed a tuple like the one returned by L{sys.exc_info}.
fooN)
ValueErrorr5   r   )r*   infos   & r   test_excInfoExcInfoTests.test_excInfo  s,    
 Ju-t4 9$ ??@r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   rF    s     
P 
Pd 
Pr   c                     ^^ ,           V P                  XP                  VP                  VP
                  3\        V4      4       R#   \          d    \        4       p LUi ; i)z
When called with a L{Failure} instance, L{excInfoOrFailureToExcInfo}
returns a tuple like the one returned by L{sys.exc_info}, with the
elements taken from the type, value, and traceback of the failure.
N)BaseExceptionr   r)   typer   tbr   )r*   fs   & r   test_failureExcInfoTests.test_failure  sQ    	E 	!&&!''14402KA2NO  		A	s   	A	 	A! A!r   N)rA   rB   rC   rD   rE   rK  rS  rF   r   r   r   rD  rD    s    A
P 
Pr   rD  c                  J    ] tR tRtRtR R ltR R ltR R ltR	 R
 ltRt	R# )AcquireAttributeTestsi  z 
Tests for L{acquireAttribute}.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   "AcquireAttributeTests.__annotate__  s     N N4 Nr   c                v    \        4       ;V n        pV P                  V\        V \        4       .R4      J 4       R# )z
The value returned by L{acquireAttribute} is the value of the requested
attribute on the first object in the list passed in which has that
attribute.
r   Nr   r   r5   r   r*   r   s   & r   test_foundOnEarlierObject/AcquireAttributeTests.test_foundOnEarlierObject  s2     $X%
U!142BG!LLMr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   rX    s     N N Nr   c                v    \        4       ;V n        pV P                  V\        \        4       V .R4      J 4       R# )z
The same as L{test_foundOnEarlierObject}, but for the case where the 2nd
element in the object list has the attribute and the first does not.
r   NrZ  r[  s   & r   test_foundOnLaterObject-AcquireAttributeTests.test_foundOnLaterObject  s2    
 $X%
U!168T2BG!LLMr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   rX    s     O O Or   c                P    V P                  \        \        \        4       .R4       R# )z}
If none of the objects passed in the list to L{acquireAttribute} have
the requested attribute, L{AttributeError} is raised.
rH  N)r  AttributeErrorr   r   rv   s   &r   test_notFoundException,AcquireAttributeTests.test_notFoundException  s    
 	.*:VXJNr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   rX    s     Q Qd Qr   c                h    \        4       pV P                  V\        \        4       .RV4      J 4       R# )z
If none of the objects passed in the list to L{acquireAttribute} have
the requested attribute and a default value is given, the default value
is returned.
rH  N)r   r5   r   )r*   defaults   & r   test_notFoundDefault*AcquireAttributeTests.test_notFoundDefault  s*     (#3VXJw#OOPr   )r   N)
rA   rB   rC   rD   rE   r\  r`  re  rj  rF   r   r   r   rV  rV    s%    NNOQ Qr   rV  c                      ] tR tRtRtR R ltR R ltR R ltR	 R
 ltR R lt	R R lt
R R ltR R ltR R ltRtR# )ListToPhraseTestsi  z
Input is transformed into a string representation of the list,
with each item separated by delimiter (defaulting to a comma) and the final
two being separated by a final delimiter.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ListToPhraseTests.__annotate__  s     + +D +r   c                ^    . pRp\         P                  ! VR4      pV P                  W#4       R# )z2
If things is empty, an empty string is returned.
 andNr   _listToPhraser)   r*   sampleexpectedresults   &   r   
test_emptyListToPhraseTests.test_empty  s.      ##FE2*r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ro    s     + +d +r   c                `    R.pRp\         P                  ! VR4      pV P                  W#4       R# )z+
With a single item, the item is returned.
Onerr  Nrs  ru  s   &   r   test_oneWordListToPhraseTests.test_oneWord  s0     ##FE2*r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ro     s     + +t +r   c                b    RR.pRp\         P                  ! VR4      pV P                  W#4       R# )z1
Two words are separated by the final delimiter.
r}  TwozOne and Tworr  Nrs  ru  s   &   r   test_twoWordsListToPhraseTests.test_twoWords   s2      ##FE2*r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ro  )  s     + + +r   c                b    . ROpRp\         P                  ! VR4      pV P                  W#4       R# )zI
With more than two words, the first two are separated by the delimiter.
zOne, Two, and Threerr  N)r}  r  Threers  ru  s   &   r   test_threeWords!ListToPhraseTests.test_threeWords)  s.     )(##FE2*r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ro  2       + + +r   c                f    . ROpRp\         P                  ! VRRR7      pV P                  W#4       R# )zG
If a delimiter is specified, it is used instead of the default comma.
zOne; Two; Three; or Fourorz; )	delimiterN)r}  r  r  Fourrs  ru  s   &   r   test_fourWords ListToPhraseTests.test_fourWords2  s0     1-##FDDA*r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ro  ;  r  r   c                b    . ROpRp\         P                  ! VR4      pV P                  W#4       R# )zC
If something in things is not a string, it is converted into one.
z1, 2, and threerr  N)   r   threers  ru  s   &   r   test_notString ListToPhraseTests.test_notString;  s.     !$##FE2*r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ro  D  s     I Id Ir   c                    RpV P                  \        \        P                  VR4      pV P	                  \        V4      R4       R# )z/
If things is a string, a TypeError is raised.
zOne, two, threerr   Things must be a list or a tupleNr  	TypeErrorr   rt  r)   rP   r*   rv  rR   s   &  r   test_stringTypeError&ListToPhraseTests.test_stringTypeErrorD  s:     #!!)T-?-?OU%GHr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ro  L  s     I I Ir   c                    \        . RO4      pV P                  \        \        P                  VR4      pV P                  \        V4      R4       R# )z2
If things is an iterator, a TypeError is raised.
rr  r  N)r  r      )iterr  r  r   rt  r)   rP   r  s   &  r   test_iteratorTypeError(ListToPhraseTests.test_iteratorTypeErrorL  s>     i!!)T-?-?OU%GHr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   ro  T  s     	I 	I 	Ir   c                    R R lpV P                  \        \        P                  VR4      pV P	                  \        V4      R4       R# )z2
If things is a generator, a TypeError is raised.
c                   V ^8  d   QhRR/# )r   r   zGenerator[int, None, None]r   )r   s   "r   r   ?ListToPhraseTests.test_generatorTypeError.<locals>.__annotate__Y  s     	  	 2 	 r   c               3  8   "   \        ^4       Rj  xL
  R#  L5i)r   N)ranger   r   r   rv  9ListToPhraseTests.test_generatorTypeError.<locals>.sampleY  s     Qxs   rr  r  Nr  r  s   &  r   test_generatorTypeError)ListToPhraseTests.test_generatorTypeErrorT  s:    
	  !!)T-?-?OU%GHr   r   N)rA   rB   rC   rD   rE   ry  r~  r  r  r  r  r  r  r  rF   r   r   r   rm  rm    s=    ++++++II	I 	Ir   rm  c                  2    ] tR tRtRtR R ltR R ltRtR# )	OpenTestLogTestsi`  z
Tests for C{openTestLog}.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   OpenTestLogTests.__annotate__e  s     = =4 =r   c                   \         P                  ! 4       pV P                  \         P                  \         P                  V4       \         P                  ! \         P                  R4       Rp\
        P                  ! V P                  4       4      p\        V4      ;_uu_ 4       pVP                  V4       RRR4       \        VP                  R4      ;_uu_ 4       pVP                  4       pRRR4       \        VP                  R4      \        X4      4       R#   + '       g   i     Lm; i  + '       g   i     LI; i)zB
The log file is opened in text mode and uses UTF-8 for encoding.
u   Here comes the ☉Nrbr  )Cascii)locale	getlocale
addCleanup	setlocaleLC_ALLr
   r  r#   r   writeopenr%   readr   r  r   )r*   currentLocaletextprR  writtens   &     r   	test_utf8OpenTestLogTests.test_utf8e  s     ((*((&--G7'dkkm,^^qGGDM  !&&$1ffhG   	DKK((7*;< ^  s   #DD-D*	-D=	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r  {  s     
 
T 
r   c                   RpRpR\         P                   R\         P                   2p\        P                  ! V P	                  4       4      p\        V4      ;_uu_ 4       pVP                  V4       RRR4       \        V4      ;_uu_ 4       pVP                  V4       RRR4       \        VP                  4       P                  R4      \        V4      4       R#   + '       g   i     Lq; i  + '       g   i     LW; i)z
The log file is opened in append mode so if runner configuration specifies
an existing log file its contents are not wiped out.
zHello, world.
 zGoodbye, world.
zHello, world.z Goodbye, world.Nr  )r$   linesepr
   r  r#   r   r  r   
getContentdecoder   )r*   existingTextnewTextrw  r  rR  s   &     r   test_appendOpenTestLogTests.test_append{  s    
 *%"2::,.>rzzlKdkkm,^^qGGL! ^^qGGG  	LLN!!'*X	
 ^^s    CC.C+	.C>	r   N)rA   rB   rC   rD   rE   r  r  rF   r   r   r   r  r  `  s    =,
 
r   r  )+rE   
__future__r   r  r$   r)  ior   typingr   zope.interfacer   hamcrestr   r   twisted.internet.baser   twisted.internet.interfacesr	   twisted.pythonr
   twisted.python.failurer   twisted.trialr   twisted.trial.unittestr   twisted.trial.utilr   r   r   r   r   r   rH   rb   r   r   r  rD  rV  rm  r  r   r   r   <module>r     s   
 #  	 
   & * - 9 # *  6 &6% &6R0
&9 0
f*  * Z* *&oV& oVdRC+ RCjP& P4$Q/ $QNVI+ VIr,
* ,
r   