+
    Dfj                        R t ^ RIt^ RIt^ RIHtHt ^ RIHtH	t	H
t
 ^ RIHtHt ^ RIHt ^ RIHtHtHt ^ RIHt ^ RIHt  ! R	 R
]4      t ! R R4      t ! R R]P2                  4      t ! R R]P6                  4      t ! R R]P6                  4      t ! R R]P6                  4      t ! R R]P6                  4      t ! R R]P6                  4      t  ! R R]P6                  4      t! ! R R]P6                  4      t" ! R R]P6                  4      t#]! ]#PH                  4      R 4       t%]! ]#PH                  R R!7      R" 4       t& ! R# R$]P6                  4      t'R% t(](t)]! ]'PH                  R&]*R'4       R( t+R# ))a  
Tests for assertions provided by C{SynchronousTestCase} and C{TestCase},
provided by L{twisted.trial.unittest}.

L{TestFailureTests} demonstrates that L{SynchronousTestCase.fail} works, so that
is the only method on C{twisted.trial.unittest.SynchronousTestCase} that is
initially assumed to work.  The test classes are arranged so that the methods
demonstrated to work earlier in the file are used by those later in the file
(even though the runner will probably not run the tests in this order).
N)VersiongetVersionString)Deferredfailsucceed)
deprecateddeprecatedModuleAttribute)Failure)accumulateMethodsfullyQualifiedNameprefixedMethods)FancyEqMixin)unittestc                   <   a  ] tR t^!t o RtR tV 3R lR ltRtV tR# )MockEqualityc                    Wn         R # Nname)selfr   s   &&D/usr/lib/python3/dist-packages/twisted/trial/test/test_assertions.py__init__MockEquality.__init__$   s    	    c                    < V ^8  d   QhRS[ /# )   return)str)format__classdict__s   "r   __annotate__MockEquality.__annotate__'   s     , ,# ,r   c                "    R V P                    R2# )zMockEquality()r   r   s   &r   __repr__MockEquality.__repr__'   s    tyyk++r   r   N)	__name__
__module____qualname____firstlineno__compareAttributesr   r%   __static_attributes____classdictcell__r   s   @r   r   r   !   s     !, ,r   r   c                   2   a  ] tR t^+t o RtR t]t]tRtV t	R# )ComparisonErrorz@
An object which raises exceptions from its comparison methods.
c                    \        R 4      h)zComparison is broken)
ValueError)r   others   &&r   _errorComparisonError._error0   s    /00r    N)
r'   r(   r)   r*   __doc__r4   __eq____ne__r,   r-   r.   s   @r   r0   r0   +   s     1 FFr   r0   c                   `   a  ] tR t^7t o Rt ! R R]P                  4      tR tR t	R t
RtV tR# )	TestFailureTestsa  
Tests for the most basic functionality of L{SynchronousTestCase}, for
failing tests.

This class contains tests to demonstrate that L{SynchronousTestCase.fail}
can be used to fail a test, and that that failure is reflected in the test
result object.  This should be sufficient functionality so that further
tests can be built on L{SynchronousTestCase} instead of
L{unittest.TestCase}.  This depends on L{unittest.TestCase} working.
c                   &   a  ] tR t^Ct o R tRtV tR# )TestFailureTests.FailingTestc                (    V P                  R 4       R# )zThis test fails.Nr   r$   s   &r   
test_fails'TestFailureTests.FailingTest.test_failsD   s    II()r   r6   N)r'   r(   r)   r*   r@   r,   r-   r.   s   @r   FailingTestr=   C   s     	* 	*r   rB   c                <   \         V P                  P                   V P                  P                   .p\        P                  ! 4       V n        V P
                  P                  RP                  V4      4      V n        \        V P                  4      ^ ,          V n
        R# )zW
Load a suite of one test which can be used to exercise the failure
handling behavior.
.N)r'   	__class__rB   pyunit
TestLoaderloaderloadTestsFromNamejoinsuitelisttest)r   
componentss   & r   setUpTestFailureTests.setUpG   sj    
  7 79I9I9R9RS
'')[[22388J3GH
$Q'	r   c                     V P                   P                  R4       V P                  R4       R#   T P                   P                   d'   pT P                  R\	        T4      4        Rp?R# Rp?ii ; i)ze
L{SynchronousTestCase.fail} raises
L{SynchronousTestCase.failureException} with the given argument.
failedzRSynchronousTestCase.fail method did not raise SynchronousTestCase.failureExceptionN)rM   r   failureExceptionassertEqualr   r   results   & r   	test_failTestFailureTests.test_failQ   s]    
	IINN8$ II7 yy)) 	4Xs6{33	4s   0 A1A,,A1c                   \         P                  ! 4       pV P                  P                  V4       V P	                  VP                  4       4       V P                  VP                  . 4       V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          ^ ,          V P                  4       R# )z~
When a test method raises L{SynchronousTestCase.failureException}, the test is
marked as having failed on the L{TestResult}.
N)rF   
TestResultrK   runassertFalsewasSuccessfulrT   errorslenfailuresrM   rU   s   & r   test_failingExceptionFails+TestFailureTests.test_failingExceptionFails`   s    
 ""$

v--/0+V__-q1+A.		:r   )rH   rK   rM   N)r'   r(   r)   r*   r7   r   SynchronousTestCaserB   rO   rW   ra   r,   r-   r.   s   @r   r;   r;   7   s0     	*h22 *(
; 
;r   r;   c                   H   a  ] tR t^mt o RtR tR tR tR tR t	R t
RtV tR	# )
AssertFalseTestsa  
Tests for L{SynchronousTestCase}'s C{assertFalse} and C{failIf} assertion
methods.

This is pretty paranoid.  Still, a certain paranoia is healthy if you
are testing a unit testing framework.

@note: As of 11.2, C{assertFalse} is preferred over C{failIf}.
c                x    ^ RRRR. 3 F-  pV! VRV: 24      pW28w  g   K  V P                  RV: 24       K/  	  R# )zj
Perform the positive case test for C{failIf} or C{assertFalse}.

@param method: The test method to test.
        FN
failed on Did not return argument r6   r?   )r   methodnotTruerV   s   &&  r   _assertFalseFalse"AssertFalseTests._assertFalseFalsex   sH     3tR4GGz'%=>F 		4WK@A 5r   c           
        ^RR^^.R
3 F5  p V! VRV: 24       V P                  RVP                  : RV: R24       K7  	  R	#   T P                   d4   pT P                  RT: 2\	        T4      RT: RT: 24        R	p?Kz  R	p?ii ; i)zj
Perform the negative case test for C{failIf} or C{assertFalse}.

@param method: The test method to test.
Tcatrh   Call to () didn't failRaised incorrect exception on : N      r   r'   rS   assertInr   )r   rj   truees   &&  r   _assertFalseTrue!AssertFalseTests._assertFalseTrue   s     eaVV4Dtz$23 		  5 ((  )F4THBqeD s   AB	(BB	c                <    V P                  V P                  4       R# )z\
L{SynchronousTestCase.failIf} returns its argument if its argument is
not considered true.
N)rl   failIfr$   s   &r   test_failIfFalse!AssertFalseTests.test_failIfFalse   s    
 	t{{+r   c                <    V P                  V P                  4       R# )za
L{SynchronousTestCase.assertFalse} returns its argument if its argument
is not considered true.
N)rl   r\   r$   s   &r   test_assertFalseFalse&AssertFalseTests.test_assertFalseFalse   s    
 	t//0r   c                <    V P                  V P                  4       R# )zr
L{SynchronousTestCase.failIf} raises
L{SynchronousTestCase.failureException} if its argument is considered
true.
N)r|   r   r$   s   &r   test_failIfTrue AssertFalseTests.test_failIfTrue   s     	dkk*r   c                <    V P                  V P                  4       R# )zw
L{SynchronousTestCase.assertFalse} raises
L{SynchronousTestCase.failureException} if its argument is considered
true.
N)r|   r\   r$   s   &r   test_assertFalseTrue%AssertFalseTests.test_assertFalseTrue   s     	d../r   r6   N)r'   r(   r)   r*   r7   rl   r|   r   r   r   r   r,   r-   r.   s   @r   re   re   m   s.     	B0,1+0 0r   re   c                   H   a  ] tR t^t o RtR tR tR tR tR t	R t
RtV tR	# )
AssertTrueTestsa  
Tests for L{SynchronousTestCase}'s C{assertTrue} and C{failUnless} assertion
methods.

This is pretty paranoid.  Still, a certain paranoia is healthy if you
are testing a unit testing framework.

@note: As of 11.2, C{assertTrue} is preferred over C{failUnless}.
c           
        ^ RRRR
. 3 F5  p V! VRV: 24       V P                  RVP                  : RV: R24       K7  	  R#   T P                   d4   pT P                  RT: 2\	        T4      RT: R	T: 24        Rp?Kz  Rp?ii ; i)zn
Perform the negative case test for C{assertTrue} and C{failUnless}.

@param method: The test method to test.
rg   FNrh   rp   rq   rr   rs   rt   r6   rx   )r   rj   rk   r{   s   &&  r   _assertTrueFalse AssertTrueTests._assertTrueFalse   s     3tR4Gw*WK 89 		  5 ((  ,F4WKr!G s   AB(BBc                z    ^RR^^.R3 F-  pV! VRV: 24      pW28w  g   K  V P                  RV: 24       K/  	  R# )zn
Perform the positive case test for C{assertTrue} and C{failUnless}.

@param method: The test method to test.
Tro   rh   ri   Nru   r?   )r   rj   rz   rV   s   &&  r   _assertTrueTrueAssertTrueTests._assertTrueTrue   sI     eaVV4DDJth"78F~		4TH=> 5r   c                <    V P                  V P                  4       R# )zz
L{SynchronousTestCase.assertTrue} raises
L{SynchronousTestCase.failureException} if its argument is not
considered true.
N)r   
assertTruer$   s   &r   test_assertTrueFalse$AssertTrueTests.test_assertTrueFalse        	doo.r   c                <    V P                  V P                  4       R# )zz
L{SynchronousTestCase.failUnless} raises
L{SynchronousTestCase.failureException} if its argument is not
considered true.
N)r   
failUnlessr$   s   &r   test_failUnlessFalse$AssertTrueTests.test_failUnlessFalse   r   r   c                <    V P                  V P                  4       R# )z\
L{SynchronousTestCase.assertTrue} returns its argument if its argument
is considered true.
N)r   r   r$   s   &r   test_assertTrueTrue#AssertTrueTests.test_assertTrueTrue       
 	T__-r   c                <    V P                  V P                  4       R# )z\
L{SynchronousTestCase.failUnless} returns its argument if its argument
is considered true.
N)r   r   r$   s   &r   test_failUnlessTrue#AssertTrueTests.test_failUnlessTrue   r   r   r6   N)r'   r(   r)   r*   r7   r   r   r   r   r   r   r,   r-   r.   s   @r   r   r      s-     0	?//.. .r   r   c                   Z  a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R  t"R! t#R" t$R# t%R$ t&R% t'R& t(R' t)R( t*R) t+R* t,]-! ].P^                  R+R,4      f   R-],n0        R.t1V t2R,# R.t1V t2R,# )/SynchronousAssertionsTestsi  a  
Tests for L{SynchronousTestCase}'s assertion methods.  That is, failUnless*,
failIf*, assert* (not covered by other more specific test classes).

Note: As of 11.2, assertEqual is preferred over the failUnlessEqual(s)
variants.  Tests have been modified to reflect this preference.

This is pretty paranoid.  Still, a certain paranoia is healthy if you are
testing a unit testing framework.
c                Z    V P                  W4      pW18w  d   V P                  R 4       R# R# )z)assertEqual should return first parameterN)rT   r   )r   firstsecondxs   &&& r   _testEqualPair)SynchronousAssertionsTests._testEqualPair  s)    U+:IIAB r   c                   Rp V P                  W4       T'       g   T P                  RT: RT: R	24       R# R#   T P                   d   p\        P                  ! R4      p TP                  Y4        Rp?Ld  TP                   dF   pRp\	        T4      p\	        T4      pY8w  d   T P                  RT: RT: 24        Rp? Rp?LRp?ii ; iRp?ii ; i)
z
Assert that when called with unequal arguments, C{assertEqual} raises a
failure exception with the same message as the standard library
C{assertEqual} would have raised.
FrO   Tz
Expected: z; Got: NzCall to assertEqual(, rr   )rT   rS   rF   TestCaser   r   )	r   r   r   raised
ourFailurecasetheirFailuregotexpecteds	   &&&      r   _testUnequalPair+SynchronousAssertionsTests._testUnequalPair  s     	GU+ II,UIRzOP  $$ 		G??7+DG  //(( G*o|,?II
8,gcWEFG			Gs9   ; CC#A99C
7C
C
CCCc                    V P                  R R 4       V P                  R R4       V P                  ^.^.4       V P                  ^.R4       R# )ro   dogorangeN)r   r   r$   s   &r   test_assertEqual_basic1SynchronousAssertionsTests.test_assertEqual_basic/  sH    E5)eU+QC!%qc8,r   c                    \        R 4      p\        R4      p\        R 4      pV P                  W4       V P                  W4       V P                  W4       V P                  W#4       R# )r   r   N)r   r   r   )r   r   yzs   &   r   test_assertEqual_custom2SynchronousAssertionsTests.test_assertEqual_custom5  sX    !"!A!A!a#a#r   c                    RpV P                  V P                  V P                  RRV4      pV P                  V\	        V4      4       R# )zQ
When a message is passed to L{assertEqual} it is included in the error
message.
messagefoobarN)assertRaisesrS   rT   ry   r   )r   r   	exceptions   &  r   test_assertEqualMessage2SynchronousAssertionsTests.test_assertEqualMessage>  sD    
 %%!!4#3#3UE7
	 	gs9~.r   c                    V P                  V P                  V P                  RRR4      pV P                  V P                  V P                  RR4      pV P                  \        V4      \        V4      4       R# )zb
If a message is specified as L{None}, it is not included in the error
message of L{assertEqual}.
r   r   N)r   rS   rT   r   )r   exceptionForNoneexceptionWithouts   &  r   test_assertEqualNoneMessage6SynchronousAssertionsTests.test_assertEqualNoneMessageI  sr    
  ,,!!4#3#3UE4
  ,,!!4#3#3UE
 	-.4D0EFr   c                    \        4       pR .p V P                  W4       V P                  RP                  W4      4       R#   T P                   d    T P                  R4        R# \
         d     R# i ; i)r   z7Comparing {!r} and {!r} should have raised an exceptionz6Fail raised when ValueError ought to have been raised.N)r0   rT   r   r   rS   r2   )r   appler   s   &  r   test_assertEqual_incomparable8SynchronousAssertionsTests.test_assertEqual_incomparableV  ss    !	U+ IIIPP $$ 	PIINO 		s   A "A5'A50A54A5c                    Vhr   r6   )r   errors   &&r   _raiseError&SynchronousAssertionsTests._raiseErrorg  s    r   c                    V P                  \        V P                  \        4      pV P                  \	        V\        4      R 4       R# )z?Expect failUnlessRaises to return instance of raised exception.N)failUnlessRaisesr2   r   r   
isinstancer   r   s   & r   test_failUnlessRaises_expected9SynchronousAssertionsTests.test_failUnlessRaises_expectedj  s5    !!*d.>.>
Kq*%P	
r   c                     V P                  \        V P                  \        4       V P	                  R 4       R#   \         d    T P	                  R4        R# T P
                   d     R# i ; i)z4Expected exception wasn't raised. Should have failedz9failUnlessRaises shouldn't re-raise unexpected exceptionsN)r   r2   r   	TypeErrorr   rS   r$   s   &r    test_failUnlessRaises_unexpected;SynchronousAssertionsTests.test_failUnlessRaises_unexpectedq  s_    	N!!*d.>.>	J IILM  	VIITU$$ 		s   %: A-A-(A-,A-c                   a ^o V P                  \        V3R l4       V P                  R4       R#   T P                   d'   pT P	                  \        T4      R4        Rp?R# Rp?ii ; i)rv   c                     < S # r   r6   )returnValues   r   <lambda>NSynchronousAssertionsTests.test_failUnlessRaises_noException.<locals>.<lambda>  s    kr   z(Exception not raised. Should have failedz"ValueError not raised (3 returned)N)r   r2   r   rS   rT   r   )r   r{   r   s   & @r   !test_failUnlessRaises_noException<SynchronousAssertionsTests.test_failUnlessRaises_noException|  s`    	B!!*.AB II@A $$ 	KSV%IJJ	Ks   2 A)A$$A)c                z   V P                  V P                  V P                  V P                  4      pV P                  \	        WP                  4      R V P                  : R24        V P                  V P                  V P                  \
        4      pV P                  R4       R#   T P                   d     R# i ; i)z	Expected z instance to be returnedzShould have raised exceptionN)r   rS   r   r   r   r2   r   r   s   & r   &test_failUnlessRaises_failureExceptionASynchronousAssertionsTests.test_failUnlessRaises_failureException  s    !!!!4#3#3T5J5J
 	q//0--00HI	
	6%%%%t'7'7A II45	 $$ 		s   '+B% %B:9B:c                    \        R4      pV P                  \         4      ;_uu_ 4       pVh  + '       g   i     M; iT P                  TXP                  4       R# )z
If C{assertRaises} is used to create a context manager and an exception
is raised from the body of the C{with} statement then the context
manager's C{exception} attribute is set to the exception that was
raised.
markerN)r2   r   assertIsr   )r   r   contexts   &  r    test_assertRaisesContextExpected;SynchronousAssertionsTests.test_assertRaisesContextExpected  sE     x(	z**gO +* 	i!2!23s   ,<	c                    V P                  \        4      ;_uu_ 4        \        R4      h  + '       g   i     M; i T P                  R4       R#   T P                   df   p\        T4      pRP                  \        \        4      R7      pT P                  TP                  T4      RP                  T4      4        Rp?R# Rp?ii ; i)z
If C{assertRaises} is used to create a context manager and the wrong
exception type is raised from the body of the C{with} statement then
the C{with} statement raises C{failureException} describing the
mismatch.
r   N:Mismatched exception type should have caused test failure.z/{type} raised instead of ValueError:
 Traceback)typez=Exception message did not begin with expected information: {})
r   r2   r   r   rS   r   r   r   r   
startswith)r   r   r   r   s   &   r   "test_assertRaisesContextUnexpected=SynchronousAssertionsTests.test_assertRaisesContextUnexpected  s    	T"":..)) /.. IIRS $$ 		)nGMUU'	2 V H OO""8,VG_ 		s%   A +;	A C#ACCc                    V P                  \        4      ;_uu_ 4         RRR4       V P                  R4       R#   + '       g   i     L#; i  T P                   d)   p\	        T4      pT P                  TR4        Rp?R# Rp?ii ; i)z
If C{assertRaises} is used to create a context manager and no exception
is raised from the body of the C{with} statement then the C{with}
statement raises C{failureException} describing the lack of exception.
Nz5Non-exception result should have caused test failure.z%ValueError not raised (None returned))r   r2   r   rS   r   rT   )r   r   r   s   &  r   #test_assertRaisesContextNoException>SynchronousAssertionsTests.test_assertRaisesContextNoException  sq    
	O"":.. / IIMN /. $$ 	O)nG W&MNN		Os+   A <A A	A B BBc                    V P                  \        \        34      ;_uu_ 4        \        4       h  + '       g   i     M; i T P	                  R4       R#   T P
                   d   p\        T4      pRT9  pRT9  p. pT'       d   TP                  R4       T'       d   TP                  R4       T'       d+   T P	                  RP                  T4      RT 24        Rp?R#  Rp?R# Rp?ii ; i)	z
If the exception type passed to C{assertRaises} does not have a
C{__name__} then the context manager still manages to construct a
descriptive string for it.
Nr   r2   r   z(expected ValueError in exception messagez'expected TypeError in exception messagez; z
message = )	r   r2   r   AttributeErrorr   rS   r   appendrJ   )r   r   r   
valueError	typeErrorr^   s   &     r   test_brokenName*SynchronousAssertionsTests.test_brokenName  s    	T""J	#:;;$&& <;; IIRS $$ 
	E)nG%W4J#72IFHIGH		$))F+z'-CDD 
	Es1   #A 0A 	A C.(7C) C)9$C))C.c                    ^.^.^.r2pV P                  W4      pV P                  WAR4       V P                  V P                  V P                   W4       V P                  V P                  V P                   W4       R# )   )failIfEqual should return first parameterN)failIfEqualrT   r   rS   r   r   r   r   rets   &    r   test_failIfEqual_basic1SynchronousAssertionsTests.test_failIfEqual_basic  sp    #sQCaq$!LMd33T5E5EqLd33T5E5EqLr   c                    \        R 4      p\        R4      p\        R4      pV P                  W4      pV P                  WAR4       V P                  V P                  V P                  W4       V P                  WR4       R# )r   r   fecundr  z"__ne__ should make these not equalN)r   r  rT   r   rS   r  s   &    r   test_failIfEqual_customEq4SynchronousAssertionsTests.test_failIfEqual_customEq  sp    !""q$!LMd33T5E5EqLCDr   c                r    \        4       p\        4       pV P                  W4      pV P                  W4       R# )zj
C{failIfIdentical} returns its first argument if its first and second
arguments are not the same object.
N)objectfailIfIdenticalrT   )r   r   r   rV   s   &   r   test_failIfIdenticalPositive7SynchronousAssertionsTests.test_failIfIdenticalPositive  s0    
 HH%%a+#r   c                h    \        4       pV P                  V P                  V P                  W4       R# )zf
C{failIfIdentical} raises C{failureException} if its first and second
arguments are the same object.
N)r  r   rS   r  r   s   & r   test_failIfIdenticalNegative7SynchronousAssertionsTests.test_failIfIdenticalNegative   s)    
 Hd33T5I5I1Pr   c                    ^.^.^.r2pV P                  W4      pV P                  WAR4       V P                  V P                  V P                   W4       V P                  V P                  V P                   W4       R# )r   z1failUnlessIdentical should return first parameterN)failUnlessIdenticalrT   r   rS   r  s   &    r   test_failUnlessIdentical3SynchronousAssertionsTests.test_failUnlessIdentical  sp    #sQCa&&q,!WXd33T5M5MqTd33T5M5MqTr   c                   R RRr2pV P                  WR4       V P                  WR4      pV P                  WAR4       V P                  V P                  V P                   WR4       V P                  V P                  V P                   WR4       R# )g      ?g?g333333?g?z4failUnlessApproximates should return first parameterg?N)failUnlessApproximatesrT   r   rS   r  s   &    r   test_failUnlessApproximates6SynchronousAssertionsTests.test_failUnlessApproximates  s    sCa##A#.))!4M	
 	!!4#>#>c	
 	!!4#>#>c	
r   c           	         ^pRpRpRpV P                  W"V4       V P                  W$V4      pV P                  VVRV: RV: R24       V P                  V P                  V P                   W#V4       R# )   A!   @XO  @C   @z5failUnlessAlmostEqual should return first parameter (r   r#   N)failUnlessAlmostEqualrT   r   rS   r   	precisionr   r   r   r  s   &     r   test_failUnlessAlmostEqual5SynchronousAssertionsTests.test_failUnlessAlmostEqual  s{    	""13((y9*-q2	
 	!!4#=#=qY	
r   c           	        ^pRpRpRpV P                  W#V4      pV P                  VVRV: RV: R24       V P                  V P                  V P                   W"V4       V P                  V P                  V P                   W$V4       R# )r  r  r  r  z1failIfAlmostEqual should return first parameter (r   r#   N)failIfAlmostEqualrT   r   rS   r!  s   &     r   test_failIfAlmostEqual1SynchronousAssertionsTests.test_failIfAlmostEqual.  s    	$$Q95MPRST	

 	!!4#9#91	
 	!!4#9#91	
r   c                   R pRpRpV P                  W4       V P                  W4      pV P                  WAR4       V P                  V P                  V P                   W4       V P                  V P                  V P                   W14       R# ro   zthe dog satzthe cat satzshould return first parameterN)failUnlessSubstringrT   r   rS   r  s   &    r   test_failUnlessSubstring3SynchronousAssertionsTests.test_failUnlessSubstring@  s|      &&&q,!@Ad33T5M5MqTd33T5M5MqTr   c                   R pRpRpV P                  W14       V P                  W4      pV P                  WAR4       V P                  V P                  V P                   W4       V P                  V P                  V P                   W4       R# r*  )failIfSubstringrT   r   rS   r  s   &    r   test_failIfSubstring/SynchronousAssertionsTests.test_failIfSubstringJ  s|    Q"""1(!@Ad33T5I5I1Pd33T5I5I1Pr   c                >    \        R4      pV P                  W4       R# )z2
L{assertIs} passes if two objects are identical.
r   N)r   r   r   as   & r   test_assertIs(SynchronousAssertionsTests.test_assertIsT  s     !ar   c                    \        R4      \        R4      r!V P                  W4       V P                  V P                  V P                  W4       R# )z5
L{assertIs} fails if two objects are not identical.
r   N)r   rT   r   rS   r   r   r4  bs   &  r   test_assertIsError-SynchronousAssertionsTests.test_assertIsError[  s?     G$l7&;1$//Er   c                t    \        R4      \        R4      r!V P                  W4       V P                  W4       R# )z9
L{assertIsNot} passes if two objects are not identical.
r   N)r   rT   assertIsNotr8  s   &  r   test_assertIsNot+SynchronousAssertionsTests.test_assertIsNotc  s1     G$l7&;1r   c                j    \        R4      pV P                  V P                  V P                  W4       R# )z4
L{assertIsNot} fails if two objects are identical.
r   N)r   r   rS   r=  r3  s   & r   test_assertIsNotError0SynchronousAssertionsTests.test_assertIsNotErrork  s,     !$//1A1A1Hr   c                Z    \        R\        3/ 4      pV! 4       pV P                  W!4       R# )z,
Test a true condition of assertIsInstance.
ANr   r  assertIsInstance)r   rD  r4  s   &  r   test_assertIsInstance0SynchronousAssertionsTests.test_assertIsInstancer  s)     vi$Ca#r   c                    \        R\        3/ 4      p\        R\        3/ 4      pV! 4       pV P                  W1V34       R# )zB
Test a true condition of assertIsInstance with multiple classes.
rD  BNrE  r   rD  rJ  r4  s   &   r   $test_assertIsInstanceMultipleClasses?SynchronousAssertionsTests.test_assertIsInstanceMultipleClassesz  s=     vi$vi$CaQ(r   c                    \        R\        3/ 4      p\        R\        3/ 4      pV! 4       pV P                  V P                  V P                  W24       R# )z&
Test an error with assertIsInstance.
rD  rJ  Nr   r  r   rS   rF  rK  s   &   r   test_assertIsInstanceError5SynchronousAssertionsTests.test_assertIsInstanceError  sI     vi$vi$C$//1F1FMr   c                    \        R\        3/ 4      p\        R\        3/ 4      p\        R\        3/ 4      pV! 4       pV P                  V P                  V P                  WBV34       R# )z;
Test an error with assertIsInstance and multiple classes.
rD  rJ  CNrO  r   rD  rJ  rS  r4  s   &    r   )test_assertIsInstanceErrorMultipleClassesDSynchronousAssertionsTests.test_assertIsInstanceErrorMultipleClasses  s]     vi$vi$vi$C$//1F1Fq6Rr   c                    V P                  V P                  V P                  ^\        R4      pV P	                  R\        V4      4       R# )z
If L{TestCase.assertIsInstance} is passed a custom message as its 3rd
argument, the message is included in the failure exception raised when
the assertion fails.
zSilly assertionN)r   rS   rF  r   ry   )r   excs   & r   "test_assertIsInstanceCustomMessage=SynchronousAssertionsTests.test_assertIsInstanceCustomMessage  sA     !!4#8#8!SBS
 	'S2r   c                ~    \        R\        3/ 4      p\        R\        3/ 4      pV! 4       pV P                  W24       R# )z/
Test a true condition of assertNotIsInstance.
rD  rJ  Nr   r  assertNotIsInstancerK  s   &   r   test_assertNotIsInstance3SynchronousAssertionsTests.test_assertNotIsInstance  s9     vi$vi$C  &r   c                    \        R\        3/ 4      p\        R\        3/ 4      p\        R\        3/ 4      pV! 4       pV P                  WBV34       R# )zD
Test a true condition of assertNotIsInstance and multiple classes.
rD  rJ  rS  Nr\  rT  s   &    r   'test_assertNotIsInstanceMultipleClassesBSynchronousAssertionsTests.test_assertNotIsInstanceMultipleClasses  sM     vi$vi$vi$C  F+r   c                    \        R\        3/ 4      pV! 4       pV P                  V P                  V P                  W!4      pV P                  \        V4      V: RV 24       R# )z)
Test an error with assertNotIsInstance.
rD  z is an instance of N)r   r  r   rS   r]  rT   r   )r   rD  r4  r   s   &   r   test_assertNotIsInstanceError8SynchronousAssertionsTests.test_assertNotIsInstanceError  s\     vi$C!!$"7"79Q9QSTXUu,?s%CDr   c                    \        R\        3/ 4      p\        R\        3/ 4      pV! 4       pV P                  V P                  V P                  W1V34       R# )z>
Test an error with assertNotIsInstance and multiple classes.
rD  rJ  N)r   r  r   rS   r]  rK  s   &   r   ,test_assertNotIsInstanceErrorMultipleClassesGSynchronousAssertionsTests.test_assertNotIsInstanceErrorMultipleClasses  sN     vi$vi$C$//1I1I1RSfUr   c                2    V P                  R^/R^/4       R# )z~
L{twisted.trial.unittest.TestCase} supports the C{assertDictEqual}
method inherited from the standard library in Python 2.7.
r4  N)assertDictEqualr$   s   &r   test_assertDictEqual/SynchronousAssertionsTests.test_assertDictEqual  s    
 	c1XQx0r   rj  Nz:assertDictEqual is not available on this version of Pythonr6   )3r'   r(   r)   r*   r7   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r  r  r#  r'  r,  r0  r5  r:  r>  rA  rG  rL  rP  rU  rY  r^  ra  rd  rg  rk  getattrr   rc   skipr,   r-   r.   s   @r   r   r     s    	C
Q.-$	/G"
	NB6$4T.O$T0ME$QU

"
$UQFI$)NS	3',EV1 x++->EMH 	!! Nr   r   c                   n   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tRtV tR# )WarningAssertionTestsi  c                j    R pV P                  \        R\        V^{4      pV P                  V^{4       R# )z 
Test basic assertWarns report.
c                 >    \         P                  ! R \        R7       V # Woo deprecatedcategorywarningswarnDeprecationWarningr4  s   &r   r   :WarningAssertionTests.test_assertWarns.<locals>.deprecated      MM*5GHHr   rt  NassertWarnsrz  __file__rT   r   r   rs   &  r   test_assertWarns&WarningAssertionTests.test_assertWarns  s7    
	  0(J
 	C r   c                    R pV P                  \        R\        V^{4      pV P                  V^{4       V P                  \        R\        VR4      pV P                  VR4       R# )ze
Test that assertWarns cleans the warning registry, so the warning is
not swallowed the second time.
c                 >    \         P                  ! R \        R7       V # rs  rw  r{  s   &r   r   GWarningAssertionTests.test_assertWarnsRegistryClean.<locals>.deprecated  r}  r   rt  A  Nr~  )r   r   r1r2s   &   r   test_assertWarnsRegistryClean3WarningAssertionTests.test_assertWarnsRegistryClean  se    	  0(J
 	S! 0(J
 	S!r   c           	     r    R pV P                  V P                  V P                  \        R\        V^{4       R# )z8
Test assertWarns failure when no warning is generated.
c                     V # r   r6   r{  s   &r   normal;WarningAssertionTests.test_assertWarnsError.<locals>.normal  s    Hr   rt  Nr   rS   r  rz  r  )r   r  s   & r   test_assertWarnsError+WarningAssertionTests.test_assertWarnsError  s8    
	 	!!	
r   c           	     r    R pV P                  V P                  V P                  \        R\        V^{4       R# )z6
Test assertWarns failure when the category is wrong.
c                 >    \         P                  ! R \        R7       V # Foo deprecatedru  rw  r{  s   &r   r   GWarningAssertionTests.test_assertWarnsWrongCategory.<locals>.deprecated  r}  r   r  N)r   rS   r  UserWarningr  r   r   s   & r   test_assertWarnsWrongCategory3WarningAssertionTests.test_assertWarnsWrongCategory  s8    
	 	!!	
r   c           	     r    R pV P                  V P                  V P                  \        R\        V^{4       R# )z5
Test assertWarns failure when the message is wrong.
c                 >    \         P                  ! R \        R7       V # r  rw  r{  s   &r   r   FWarningAssertionTests.test_assertWarnsWrongMessage.<locals>.deprecated   r}  r   Bar deprecatedNr  r  s   & r   test_assertWarnsWrongMessage2WarningAssertionTests.test_assertWarnsWrongMessage  s8    
	 	!!	
r   c           	     r    R pV P                  V P                  V P                  \        R\        V^{4       R# )z
If the warning emitted by a function refers to a different file than is
passed to C{assertWarns}, C{failureException} is raised.
c                 @    \         P                  ! R \        ^R7       R# )r  )rv  
stacklevelNrw  r{  s   &r   r   CWarningAssertionTests.test_assertWarnsWrongFile.<locals>.deprecated4  s     MM*5GTUVr   r  Nr  r  s   & r   test_assertWarnsWrongFile/WarningAssertionTests.test_assertWarnsWrongFile.  s;    
	W 	!! 	
r   c                     ! R R4      pV P                  \        R\        V4      pV P                  \	        W!4      4       V P                  \        R\        V4      pV P                  \	        W!4      4       R# )z8
Test assertWarns works when creating a class instance.
c                   &   a  ] tR tRt o R tRtV tR# );WarningAssertionTests.test_assertWarnsOnClass.<locals>.WarniR  c                >    \         P                  ! R \        R7       R# )Do not call meru  N)rx  ry  RuntimeWarningr$   s   &r   r   DWarningAssertionTests.test_assertWarnsOnClass.<locals>.Warn.__init__S  s    .Hr   r6   N)r'   r(   r)   r*   r   r,   r-   r.   s   @r   Warnr  R  s     I Ir   r  r  N)r  r  r  r   r   )r   r  r  s   &  r   test_assertWarnsOnClass-WarningAssertionTests.test_assertWarnsOnClassM  s`    
	I 	I ^-=xN
1+,^-=xN
1+,r   c                    ! R R4      pV! 4       pV P                  \        R\        VP                  R4      pV P	                  VR4       V P                  \        R\        VP                  R4      pV P	                  VR4       R# )z9
Test assertWarns works when used on an instance method.
c                   &   a  ] tR tRt o R tRtV tR# )<WarningAssertionTests.test_assertWarnsOnMethod.<locals>.Warni`  c                >    \         P                  ! R \        R7       V# )r  ru  rw  r3  s   &&r   r   GWarningAssertionTests.test_assertWarnsOnMethod.<locals>.Warn.deprecateda      .9KLr   r6   N)r'   r(   r)   r*   r   r,   r-   r.   s   @r   r  r  `        r   r  r  r  N)r  rz  r  r   rT   r   r  wr  s   &   r   test_assertWarnsOnMethod.WarningAssertionTests.test_assertWarnsOnMethod[  sy    
	 	
 F 0(ALL#
 	C  0(ALL#
 	C r   c                     ! R R4      pV! 4       pV P                  \        R\        VR4      pV P                  VR4       V P                  \        R\        VR4      pV P                  VR4       R# )z=
Test assertWarns works on instance with C{__call__} method.
c                   &   a  ] tR tRt o R tRtV tR# ):WarningAssertionTests.test_assertWarnsOnCall.<locals>.Warnit  c                >    \         P                  ! R \        R7       V# )Egg deprecatedru  rw  r3  s   &&r   __call__CWarningAssertionTests.test_assertWarnsOnCall.<locals>.Warn.__call__u  r  r   r6   N)r'   r(   r)   r*   r  r,   r-   r.   s   @r   r  r  t  r  r   r  r  r  Nr~  r  s   &   r   test_assertWarnsOnCall,WarningAssertionTests.test_assertWarnsOnCallo  sk    
	 	
 F/1A8QPSTC /1A8QPSTC r   c                j    R pV P                  \        R\        V^{4      pV P                  V^{4       R# )z4
Test assertWarns on a warning filtered by default.
c                 >    \         P                  ! R \        R7       V # rs  rx  ry  PendingDeprecationWarningr{  s   &r   r   @WarningAssertionTests.test_assertWarnsFilter.<locals>.deprecated  s    MM*5NOHr   rt  N)r  r  r  rT   r  s   &  r   test_assertWarnsFilter,WarningAssertionTests.test_assertWarnsFilter  s7    
	 %'7:s
 	C r   c                R   a R oV3R lpV P                  \        R\        V4       R# )zs
C{assertWarns} does not raise an exception if the function it is passed
triggers the same warning more than once.
c                  >    \         P                  ! R \        R7       R# )rt  ru  Nr  r6   r   r   r   JWarningAssertionTests.test_assertWarnsMultipleWarnings.<locals>.deprecated  s    MM*5NOr   c                  $   < S ! 4        S ! 4        R # r   r6   )r   s   r   fAWarningAssertionTests.test_assertWarnsMultipleWarnings.<locals>.f  s    LLr   rt  N)r  r  r  )r   r  r   s   & @r    test_assertWarnsMultipleWarnings6WarningAssertionTests.test_assertWarnsMultipleWarnings  s'    	P	 	24DhPQRr   c           	         R pV P                  V P                  V P                  \        R\        V^{4      pV P                  \        V4      R4       R# )zy
For now, assertWarns is unable to handle multiple different warnings,
so it should raise an exception if it's the case.
c                 v    \         P                  ! R \        R7       \         P                  ! R\        R7       R# )rt  ru  zAnother oneN)rx  ry  rz  r  r{  s   &r   r   KWarningAssertionTests.test_assertWarnsDifferentWarnings.<locals>.deprecated  s!    MM*5GHMM-2KLr   rt  zCan't handle different warningsN)r   rS   r  rz  r  rT   r   )r   r   r{   s   &  r   !test_assertWarnsDifferentWarnings7WarningAssertionTests.test_assertWarnsDifferentWarnings  sR    	M !!
 	Q!BCr   c                   a  ! R R\         4      oV3R lpV! R4       V P                  SR\        VR4       V P                  V.4      w  pV P	                  VR,          R4       R# )z
Warnings emitted before L{TestCase.assertWarns} is called do not get
flushed and do not alter the behavior of L{TestCase.assertWarns}.
c                       ] tR tRtRtR# )PWarningAssertionTests.test_assertWarnsAfterUnassertedWarning.<locals>.TheWarningi  r6   N)r'   r(   r)   r*   r,   r6   r   r   
TheWarningr    s    r   r  c                 8   < \         P                  ! V SR 7       R# )ru  N)rx  ry  )r   r  s   &r   r  GWarningAssertionTests.test_assertWarnsAfterUnassertedWarning.<locals>.f  s    MM'J7r   r   r   r   N)Warningr  r  flushWarningsrT   )r   r  warningr  s   &  @r   &test_assertWarnsAfterUnassertedWarning<WarningAssertionTests.test_assertWarnsAfterUnassertedWarning  s\    	 		8 	
%UHa?&&s+	+U3r   r6   N)r'   r(   r)   r*   r  r  r  r  r  r  r  r  r  r  r  r  r  r,   r-   r.   s   @r   rp  rp    sM     !"(
$
&
&
>-!(! !SD*4 4r   rp  c                      a  ] tR tRt o Rt]! 4       t]! ]! R4      4      t	R t
R tR tR tR tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )ResultOfAssertionsTestsi  z
Tests for L{SynchronousTestCase.successResultOf},
L{SynchronousTestCase.failureResultOf}, and
L{SynchronousTestCase.assertNoResult}.
	Bad timesc                d    V P                  V P                  V P                  \        4       4       R# )z
L{SynchronousTestCase.successResultOf} raises
L{SynchronousTestCase.failureException} when called with a L{Deferred}
with no current result.
N)r   rS   successResultOfr   r$   s   &r   test_withoutResult*ResultOfAssertionsTests.test_withoutResult  $     	$//1E1ExzRr   c                z    V P                  V P                  V P                  \        V P                  4      4       R# )z
L{SynchronousTestCase.successResultOf} raises
L{SynchronousTestCase.failureException} when called with a L{Deferred}
with a failure result.
N)r   rS   r  r   failurer$   s   &r   test_successResultOfWithFailure7ResultOfAssertionsTests.test_successResultOfWithFailure  s.     	!!4#7#7dll9K	
r   c                     V P                  \        V P                  4      4       R#   T P                   d?   pT P	                  T P                  P                  4       \        T4      4        Rp?R# Rp?ii ; i)z
L{SynchronousTestCase.successResultOf} raises a
L{SynchronousTestCase.failureException} that has the original failure
traceback when called with a L{Deferred} with a failure result.
N)r  r   r  rS   ry   getTracebackr   r   r{   s   & r   +test_successResultOfWithFailureHasTracebackCResultOfAssertionsTests.test_successResultOfWithFailureHasTraceback  sV    	?  dll!34$$ 	?MM$,,335s1v>>	?s   $( A73A22A7c                d    V P                  V P                  V P                  \        4       4       R# )z
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a L{Deferred}
with no current result.
N)r   rS   failureResultOfr   r$   s   &r   !test_failureResultOfWithoutResult9ResultOfAssertionsTests.test_failureResultOfWithoutResult  r  r   c                z    V P                  V P                  V P                  \        V P                  4      4       R# )z
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a L{Deferred}
with a success result.
N)r   rS   r  r   rV   r$   s   &r   test_failureResultOfWithSuccess7ResultOfAssertionsTests.test_failureResultOfWithSuccess  s.     	!!4#7#79M	
r   c                    V P                  V P                  V P                  \        V P                  4      \
        4       R# )z
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a L{Deferred}
that fails with an exception type that was not expected.
N)r   rS   r  r   r  KeyErrorr$   s   &r   $test_failureResultOfWithWrongFailure<ResultOfAssertionsTests.test_failureResultOfWithWrongFailure  s0     	!!4#7#7dll9KX	
r   c                &    V P                  \        V P                  4      \        4       R#   T P                   dS   pT P                  RP                  \        P                  \        P                  4      \        T4      4        Rp?R# Rp?ii ; i)a  
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a L{Deferred}
that fails with an exception type that was not expected, and the
L{SynchronousTestCase.failureException} message contains the expected
exception type.
#Failure of type ({}.{}) expected onN)
r  r   r  r  rS   ry   r   r(   r'   r   r  s   & r   6test_failureResultOfWithWrongFailureOneExpectedFailureNResultOfAssertionsTests.test_failureResultOfWithWrongFailureOneExpectedFailure  so    	  dll!3X>$$ 	MM5<<''):): A	 	s   )- BABBc                     V P                  \        V P                  4      \        4       R#   T P                   d?   pT P                  T P                  P                  4       \        T4      4        Rp?R# Rp?ii ; i)a  
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a L{Deferred}
that fails with an exception type that was not expected, and the
L{SynchronousTestCase.failureException} message contains the original
failure traceback.
N)r  r   r  r  rS   ry   r  r   r  s   & r   ;test_failureResultOfWithWrongFailureOneExpectedFailureHasTBSResultOfAssertionsTests.test_failureResultOfWithWrongFailureOneExpectedFailureHasTB  sX    	?  dll!3X>$$ 	?MM$,,335s1v>>	?s   )- A<3A77A<c           	     l    V P                  \        V P                  4      \        \        4       R#   T P
                   dq   pT P                  RP                  \        P                  \        P                  \        P                  \        P                  4      \        T4      4        Rp?R# Rp?ii ; i)a  
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a L{Deferred}
with an exception type that was not expected, and the
L{SynchronousTestCase.failureException} message contains the expected
exception types in the error message.
,Failure of type ({}.{} or {}.{}) expected onN)r  r   r  r  IOErrorrS   ry   r   r(   r'   r   r  s   & r   9test_failureResultOfWithWrongFailureMultiExpectedFailuresQResultOfAssertionsTests.test_failureResultOfWithWrongFailureMultiExpectedFailures%  s    	  dll!3XwG$$ 		MM>EE''%%&&$$	 A 		s   .2 B3A%B..B3c                    V P                  \        V P                  4      \        \        4       R#   T P
                   d?   pT P                  T P                  P                  4       \        T4      4        Rp?R# Rp?ii ; i)a  
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a L{Deferred}
with an exception type that was not expected, and the
L{SynchronousTestCase.failureException} message contains the original
failure traceback in the error message.
N)	r  r   r  r  r  rS   ry   r  r   r  s   & r   >test_failureResultOfWithWrongFailureMultiExpectedFailuresHasTBVResultOfAssertionsTests.test_failureResultOfWithWrongFailureMultiExpectedFailuresHasTB:  sZ    	?  dll!3XwG$$ 	?MM$,,335s1v>>	?s   .2 B3A<<Bc                    V P                  V P                  V P                  \        V P                  4      4      4       R# )z
When passed a L{Deferred} which currently has a result (ie,
L{Deferred.addCallback} would cause the added callback to be called
before C{addCallback} returns), L{SynchronousTestCase.successResultOf}
returns that result.
N)assertIdenticalrV   r  r   r$   s   &r   %test_successResultOfWithSuccessResult=ResultOfAssertionsTests.test_successResultOfWithSuccessResultG  s,     	T[[$*>*>wt{{?S*TUr   c                    V P                  V P                  V P                  \        V P                  4      V P                  P                  \
        4      4       R# )a  
When passed a L{Deferred} which currently has a L{Failure} result (ie,
L{Deferred.addErrback} would cause the added errback to be called
before C{addErrback} returns), L{SynchronousTestCase.failureResultOf}
returns that L{Failure} if its contained exception type is expected.
N)r  r  r  r   r   r  r$   s   &r   -test_failureResultOfWithExpectedFailureResultEResultOfAssertionsTests.test_failureResultOfWithExpectedFailureResultP  s>     	LL  dll!3T\\5F5FQ	
r   c                    V P                  V P                  V P                  \        V P                  4      4      4       R# )z
When passed a L{Deferred} which currently has a L{Failure} result
(ie, L{Deferred.addErrback} would cause the added errback to be called
before C{addErrback} returns), L{SynchronousTestCase.failureResultOf}
returns that L{Failure}.
N)r  r  r  r   r$   s   &r   %test_failureResultOfWithFailureResult=ResultOfAssertionsTests.test_failureResultOfWithFailureResult\  s,     	T\\4+?+?T\\@R+STr   c                z    V P                  V P                  V P                  \        V P                  4      4       R# )z
When passed a L{Deferred} which currently has a success result (see
L{test_withSuccessResult}), L{SynchronousTestCase.assertNoResult}
raises L{SynchronousTestCase.failureException}.
N)r   rS   assertNoResultr   rV   r$   s   &r   test_assertNoResultSuccess2ResultOfAssertionsTests.test_assertNoResultSuccesse  s.     	!!4#6#68L	
r   c                z    V P                  V P                  V P                  \        V P                  4      4       R# )z
When passed a L{Deferred} which currently has a failure result (see
L{test_withFailureResult}), L{SynchronousTestCase.assertNoResult}
raises L{SynchronousTestCase.failureException}.
N)r   rS   r  r   r  r$   s   &r   test_assertNoResultFailure2ResultOfAssertionsTests.test_assertNoResultFailureo  s.     	!!4#6#6T\\8J	
r   c                8    V P                  \        4       4       R# )zv
When passed a L{Deferred} with no current result,
L{SynchronousTestCase.assertNoResult} does not raise an exception.
N)r  r   r$   s   &r   test_assertNoResult+ResultOfAssertionsTests.test_assertNoResulty  s    
 	HJ'r   c                    \        4       pV P                  V4       VP                  V P                  4       V P	                  V P                  V P                  V4      4       R# )z
When passed a L{Deferred} with no current result, which is then
fired with a success result, L{SynchronousTestCase.assertNoResult}
doesn't modify the result of the L{Deferred}.
Nr   r  callbackrV   rT   r  r   ds   & r   $test_assertNoResultPropagatesSuccess<ResultOfAssertionsTests.test_assertNoResultPropagatesSuccess  sH     JA	

4;;d&:&:1&=>r   c                    \        4       pV P                  V4       VP                  V P                  4       V P	                  V P                  V P                  V4      4       R# )z
When passed a L{Deferred} with no current result, which is then
fired with a L{Failure} result, L{SynchronousTestCase.assertNoResult}
doesn't modify the result of the L{Deferred}.
N)r   r  errbackr  rT   r  r(  s   & r   )test_assertNoResultPropagatesLaterFailureAResultOfAssertionsTests.test_assertNoResultPropagatesLaterFailure  sH     JA			$,,t';';A'>?r   c                    \        V P                  4      p V P                  V4       V P	                  RV P                  V4      4       R#   T P                   d     L6i ; i)
When passed a L{Deferred} which currently has a L{Failure} result,
L{SynchronousTestCase.assertNoResult} changes the result of the
L{Deferred} to a success.
Nr   r  r  rS   rT   r  r(  s   & r   +test_assertNoResultSwallowsImmediateFailureCResultOfAssertionsTests.test_assertNoResultSwallowsImmediateFailure  s\     	" 	t33A67 $$ 		s   A AAr6   N)r'   r(   r)   r*   r7   r  rV   r	   	Exceptionr  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r   r#  r*  r.  r3  r,   r-   r.   s   @r   r  r    s      XFi,-GS
	?S

$?*?V

U

(	?	@8 8r   r  c                      a  ] tR tRt o Rt]! 4       t]! R4      t]	! ]4      t
R tR tRR ltR tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t Rt!V t"R# ) ResultOfCoroutineAssertionsTestsi  z
Tests for L{SynchronousTestCase.successResultOf},
L{SynchronousTestCase.failureResultOf}, and
L{SynchronousTestCase.assertNoResult} when given a coroutine.
r  c                "   "   V P                   # 5ir   )rV   r$   s   &r   successResult.ResultOfCoroutineAssertionsTests.successResult  s     {{s   c                6   "   \        4       G R j  xL
  R #  L5ir   )r   r$   s   &r   noCurrentResult0ResultOfCoroutineAssertionsTests.noCurrentResult  s     js   Nc                .   "   Vf   V P                   pVh5ir   )r   r   r   s   &&r   raisesException0ResultOfCoroutineAssertionsTests.raisesException  s     Is   c                p    V P                  V P                  V P                  V P                  4       4       R# )z
L{SynchronousTestCase.successResultOf} raises
L{SynchronousTestCase.failureException} when called with a coroutine
with no current result.
N)r   rS   r  r<  r$   s   &r   r  3ResultOfCoroutineAssertionsTests.test_withoutResult  .     	!!4#7#79M9M9O	
r   c                p    V P                  V P                  V P                  V P                  4       4       R# )z
L{SynchronousTestCase.successResultOf} raises
L{SynchronousTestCase.failureException} when called with a coroutine
that raises an exception.
N)r   rS   r  r@  r$   s   &r   !test_successResultOfWithExceptionBResultOfCoroutineAssertionsTests.test_successResultOfWithException  rD  r   c                   \        R4      p V P                  V P                  V4      4       R#   T P                   dB   pT P	                  R\        T4      4       T P	                  R\        T4      4        Rp?R# Rp?ii ; i)z
L{SynchronousTestCase.successResultOf} raises a
L{SynchronousTestCase.failureException} that has the original failure
traceback when called with a coroutine with a failure result.
r  zSuccess result expected onbuiltins.Exception: Bad timesN)r5  r  r@  rS   ry   r   r   r   r{   s   &  r   r  LResultOfCoroutineAssertionsTests.test_successResultOfWithFailureHasTraceback  sn     k*		C  !5!5i!@A$$ 	CMM6A?MM93q6BB	Cs    / B 6A<<Bc                p    V P                  V P                  V P                  V P                  4       4       R# )z
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a coroutine
with no current result.
N)r   rS   r  r<  r$   s   &r   r  BResultOfCoroutineAssertionsTests.test_failureResultOfWithoutResult  rD  r   c                p    V P                  V P                  V P                  V P                  4       4       R# )z
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a coroutine
with a success result.
N)r   rS   r  r9  r$   s   &r   r  @ResultOfCoroutineAssertionsTests.test_failureResultOfWithSuccess  s.     	!!4#7#79K9K9M	
r   c                z    V P                  V P                  V P                  V P                  4       \        4       R# )z
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a coroutine
that raises an exception that was not expected.
N)r   rS   r  r@  r  r$   s   &r   r   EResultOfCoroutineAssertionsTests.test_failureResultOfWithWrongFailure  s3     	!!    "		
r   c                    V P                  V P                  4       \        4       R#   T P                   dS   pT P	                  RP                  \        P                  \        P                  4      \        T4      4        Rp?R# Rp?ii ; i)a  
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a coroutine
that raises an exception with a failure type that was not expected, and
the L{SynchronousTestCase.failureException} message contains the
expected exception type.
r  N)	r  r@  r  rS   ry   r   r(   r'   r   r  s   & r   :test_failureResultOfWithWrongExceptionOneExpectedException[ResultOfCoroutineAssertionsTests.test_failureResultOfWithWrongExceptionOneExpectedException  so    	  !5!5!7B$$ 	MM5<<''):): A	 	s   $( BABBc                   \        R4      p V P                  V P                  V4      \        4       R#   T P                   dB   pT P                  R\        T4      4       T P                  R\        T4      4        Rp?R# Rp?ii ; i)a  
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a coroutine
that raises an exception with a failure type that was not expected, and
the L{SynchronousTestCase.failureException} message contains the
original exception traceback.
r  z/Failure of type (builtins.KeyError) expected onrI  N)r5  r  r@  r  rS   ry   r   rJ  s   &  r   ?test_failureResultOfWithWrongExceptionOneExpectedExceptionHasTB`ResultOfCoroutineAssertionsTests.test_failureResultOfWithWrongExceptionOneExpectedExceptionHasTB  sq     k*		C  !5!5i!@(K$$ 	CMMKSQRVTMM93q6BB	Cs   %4 B6BBc           	     b    V P                  V P                  4       \        \        4       R#   T P                   dq   pT P                  RP                  \        P                  \        P                  \        P                  \        P                  4      \        T4      4        Rp?R# Rp?ii ; i)a  
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a coroutine
that raises an exception of a type that was not expected, and the
L{SynchronousTestCase.failureException} message contains expected
exception types in the error message.
r
  N)
r  r@  r  r  rS   ry   r   r(   r'   r   r  s   & r   =test_failureResultOfWithWrongExceptionMultiExpectedExceptions^ResultOfCoroutineAssertionsTests.test_failureResultOfWithWrongExceptionMultiExpectedExceptions  s    	  !5!5!77K$$ 		MM>EE''%%&&$$	 A 		s   )- B.A%B))B.c                   \        R4      p V P                  V P                  V4      \        \        4       R#   T P
                   dB   pT P                  R\        T4      4       T P                  R\        T4      4        Rp?R# Rp?ii ; i)a&  
L{SynchronousTestCase.failureResultOf} raises
L{SynchronousTestCase.failureException} when called with a coroutine
that raises an exception of a type that was not expected, and the
L{SynchronousTestCase.failureException} message contains the original
exception traceback in the error message.
r  zCFailure of type (builtins.KeyError or builtins.OSError) expected onrI  N)r5  r  r@  r  r  rS   ry   r   rJ  s   &  r   Btest_failureResultOfWithWrongExceptionMultiExpectedExceptionsHasTBcResultOfCoroutineAssertionsTests.test_failureResultOfWithWrongExceptionMultiExpectedExceptionsHasTB2  sw     k*		C  !5!5i!@(GT$$ 	CMMUA MM93q6BB	Cs   *9 B
6BBc                x    V P                  V P                  V P                  V P                  4       4      4       R# )z
When passed a coroutine which currently has a result (ie, if converted
into a L{Deferred}, L{Deferred.addCallback} would cause the added
callback to be called before C{addCallback} returns),
L{SynchronousTestCase.successResultOf} returns that result.
N)r  rV   r  r9  r$   s   &r   r  FResultOfCoroutineAssertionsTests.test_successResultOfWithSuccessResultE  s,     	T[[$*>*>t?Q?Q?S*TUr   c                    V P                  V P                  P                  V P                  V P	                  4       V P                  P
                  \        4      P                  4       R# )aB  
When passed a coroutine which currently has an exception result (ie, if
converted into a L{Deferred}, L{Deferred.addErrback} would cause the
added errback to be called before C{addErrback} returns),
L{SynchronousTestCase.failureResultOf} returns a L{Failure} containing
that exception, if the exception type is expected.
N)rT   r  valuer  r@  r   r  r$   s   &r   )test_failureResultOfWithExpectedExceptionJResultOfCoroutineAssertionsTests.test_failureResultOfWithExpectedExceptionN  sL     	LL  $$&(9(98e		
r   c                    V P                  V P                  P                  V P                  V P	                  4       4      P                  4       R# )a'  
When passed a coroutine which currently has an exception result (ie, if
converted into a L{Deferred}, L{Deferred.addErrback} would cause the
added errback to be called before C{addErrback} returns),
L{SynchronousTestCase.failureResultOf} returns returns a L{Failure}
containing that exception.
N)rT   r  ra  r  r@  r$   s   &r   !test_failureResultOfWithExceptionBResultOfCoroutineAssertionsTests.test_failureResultOfWithException]  s;     	LL 4 4T5I5I5K L R R	
r   c                p    V P                  V P                  V P                  V P                  4       4       R# )z
When passed a coroutine which currently has a success result (see
L{test_withSuccessResult}), L{SynchronousTestCase.assertNoResult}
raises L{SynchronousTestCase.failureException}.
N)r   rS   r  r9  r$   s   &r   r  ;ResultOfCoroutineAssertionsTests.test_assertNoResultSuccessi  s.     	!!4#6#68J8J8L	
r   c                p    V P                  V P                  V P                  V P                  4       4       R# )z
When passed a coroutine which currently has an exception result (see
L{test_withFailureResult}), L{SynchronousTestCase.assertNoResult}
raises L{SynchronousTestCase.failureException}.
N)r   rS   r  r@  r$   s   &r   r   ;ResultOfCoroutineAssertionsTests.test_assertNoResultFailures  s.     	!!4#6#68L8L8N	
r   c                D    V P                  V P                  4       4       R# )zt
When passed a coroutine with no current result,
L{SynchronousTestCase.assertNoResult} does not raise an exception.
N)r  r<  r$   s   &r   r#  4ResultOfCoroutineAssertionsTests.test_assertNoResult}  s    
 	D0023r   c                   a \        4       oV3R lpV! 4       pV P                  S4       SP                  V P                  4       V P	                  V P                  V P                  V4      4       R# )z
When passed a coroutine awaiting a L{Deferred} with no current result,
which is then fired with a success result,
L{SynchronousTestCase.assertNoResult} doesn't modify the result of the
L{Deferred}.
c                  $   <"   S G R j  xL
 #  L5ir   r6   r)  s   r   r<  ^ResultOfCoroutineAssertionsTests.test_assertNoResultPropagatesSuccess.<locals>.noCurrentResult       7N7   Nr&  )r   r<  cr)  s   &  @r   r*  EResultOfCoroutineAssertionsTests.test_assertNoResultPropagatesSuccess  sX     J	 A	

4;;d&:&:1&=>r   c                  a \        V P                  4      p\        4       oV3R lpV! 4       pV P                  S4       SP	                  V4       V P                  VP                  V P                  V4      P                  4       R# )z
When passed a coroutine awaiting a L{Deferred} with no current result,
which is then fired with a L{Failure} result,
L{SynchronousTestCase.assertNoResult} doesn't modify the result of the
L{Deferred}.
c                  $   <"   S G R j  xL
 #  L5ir   r6   ro  s   r   r<  cResultOfCoroutineAssertionsTests.test_assertNoResultPropagatesLaterFailure.<locals>.noCurrentResult  rq  rr  N)r	   r   r   r  r-  rT   ra  r  )r   r  r<  rs  r)  s   &   @r   r.  JResultOfCoroutineAssertionsTests.test_assertNoResultPropagatesLaterFailure  sg     DNN#J	 A			!$"6"6q"9"?"?@r   c                   a \        V P                  4      oV3R lpV! 4       p V P                  S4       V P	                  RV P                  V4      4       R#   T P                   d     L6i ; i)r1  c                  $   <"   S G R j  xL
 #  L5ir   r6   ro  s   r   r@  eResultOfCoroutineAssertionsTests.test_assertNoResultSwallowsImmediateFailure.<locals>.raisesException  rq  rr  Nr2  )r   r@  rs  r)  s   &  @r   r3  LResultOfCoroutineAssertionsTests.test_assertNoResultSwallowsImmediateFailure  sl     	 	" 	t33A67 $$ 		s   A A-,A-r6   r   )#r'   r(   r)   r*   r7   r  rV   r5  r   r	   r  r9  r<  r@  r  rF  r  r  r  r   rS  rV  rY  r\  r  rb  re  r  r   r#  r*  r.  r3  r,   r-   r.   s   @r   r7  r7    s      XF+&Ii G


C


$C*C&V




4?"A$8 8r   r7  c                   B   a  ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
AssertionNamesTestsi  zC
Tests for consistency of naming within TestCase assertion methods
c                    / p\        WR 4       V Uu. uF,  q"P                  R4      '       d   K  VR8w  g   K$  W,          NK.  	  up# u upi )assertNot_)r
   r   )r   dctks   &  r   _getAssertsAssertionNamesTests._getAsserts  s@    $X. #L1<<+>18LLLs   AAAc                    VP                   # r   )r'   r   s   &&r   _nameAssertionNamesTests._name  s    zzr   c                    \        V P                  4       4      p\        \        V R4      4      pV P                  W!P	                  V4      4       R# )a}  
The C{failUnless*} test methods are a subset of the C{assert*} test
methods.  This is intended to ensure that methods using the
I{failUnless} naming scheme are not added without corresponding methods
using the I{assert} naming scheme.  The I{assert} naming scheme is
preferred, and new I{assert}-prefixed methods may be added without
corresponding I{failUnless}-prefixed methods.
r   N)setr  r   rT   intersection)r   assertsfailUnlessess   &  r   test_failUnlessMatchesAssert0AssertionNamesTests.test_failUnlessMatchesAssert  sA     d&&()?4>?';';L'IJr   c                    \        \        P                  R 4      p\        \        P                  R4      pV P                  \	        WP
                  R7      \	        W P
                  R7      4       R# )	assertNotr   )keyN)r   r   rc   rT   sortedr  )r   r  failIfss   &  r   test_failIf_matches_assertNot1AssertionNamesTests.test_failIf_matches_assertNot  sK    !(">">L!(">">I7

+VG-L	
r   c           
        \        V 4      P                  4        F  w  r\        V4      '       g   K  VP                  R 4      '       dK   V P	                  \        WR,           4      V RV R24       V P                  V\        WR,           4      4       VP                  R4      '       g   K  V P	                  \        WRR 4      V RVRR  24       V P                  V\        WRR 4      4       K  	  R# )Equalsz but no EqualsN)varsitemscallableendswithr   hasattrrT   rm  )r   r   ra  s   &  r   test_equalSpelling&AssertionNamesTests.test_equalSpelling  s    :++-KDE??}}W%%Sj 9dV8D6QR;ST  Sj(AB}}X&&3Bi 8TF(4PSQS9+:VW  3Bi(@A .r   r6   N)r'   r(   r)   r*   r7   r  r  r  r  r  r,   r-   r.   s   @r   r~  r~    s,     M
K
	B 	Br   r~  c                   d   a  ] tR tRt o Rt]! R^^ ^ 4      tR tR tR t	R t
R tR	 tR
 tRtV tR# )CallDeprecatedTestsi  zT
Test use of the L{SynchronousTestCase.callDeprecated} method with version objects.
Twistedc                    V P                  V P                  \        R4       V P                  V P	                  4       . R4       R# )zR
callDeprecated calls a deprecated callable, suppressing the
deprecation warning.
r   zNo warnings should be shownN)callDeprecatedversion	oldMethodrT   r  r$   s   &r   $test_callDeprecatedSuppressesWarning8CallDeprecatedTests.test_callDeprecatedSuppressesWarning  s6    
 	DLL)U;++-r3PQr   c                l    V P                  V P                  \        R4      pV P                  RV4       R# )zV
L{callDeprecated} actually calls the callable passed to it, and
forwards the result.
r   N)r  r  r  rT   rU   s   & r    test_callDeprecatedCallsFunction4CallDeprecatedTests.test_callDeprecatedCallsFunction  s,    
 $$T\\9eD'r   c                    R pV P                  V P                  V P                  V P                  V4      pV P	                  RV,          \        V4      4       R# )zL
L{callDeprecated} raises a test failure if the callable is not
deprecated.
c                      R # r   r6   r6   r   r   notDeprecatedGCallDeprecatedTests.test_failsWithoutDeprecation.<locals>.notDeprecated  s    r   z%r is not deprecated.N)r   rS   r  r  rT   r   )r   r  r   s   &  r   test_failsWithoutDeprecation0CallDeprecatedTests.test_failsWithoutDeprecation  sN    	 %%!!4#6#6m
	 	0=@#i.Qr   c                    \        R^^^4      pV P                  V P                  V P                  V\        R4      pV P                  \        V P                  4      \        V4      4       V P                  \        V4      \        V4      4       R# )zq
callDeprecated raises a test failure if the callable was deprecated
at a different version to the one expected.
Foor   N)	r   r   rS   r  r  ry   r   r  r   )r   differentVersionr   s   &  r   "test_failsWithIncorrectDeprecation6CallDeprecatedTests.test_failsWithIncorrectDeprecation  sw    
 #5!Q2%%!!
	 	&t||4c)nE&'78#i.Ir   c                    \        R^^^4      pR p\        V4      ! V4      pV P                  W^4       V P                  4       pV P	                  \        V4      ^RV 24       R# )a  
L{callDeprecated} ignores all deprecations apart from the first.

Multiple warnings are generated when a deprecated function calls
another deprecated function. The first warning is the one generated by
the explicitly called function. That's the warning that we care about.
r  c                      \        V !  # r   )r  )argss   *r   nestedDeprecationECallDeprecatedTests.test_nestedDeprecation.<locals>.nestedDeprecation&  s    d##r   zUnexpected warnings: N)r   r   r  r  rT   r_   )r   r  r  warningsShowns   &   r   test_nestedDeprecation*CallDeprecatedTests.test_nestedDeprecation  sn     #5!Q2	$ ''789JK,D
 **,]+Q2G0WXr   c                L    V P                  V P                  R3\        ^4       R# )zR
L{callDeprecated} can take a message argument used to check the warning
emitted.
	newMethodN)r  r  oldMethodReplacedr$   s   &r   test_callDeprecationWithMessage3CallDeprecatedTests.test_callDeprecationWithMessage3  s     
 	T\\;79JANr   c                
   V P                  V P                  V P                  V P                  R3\        ^4      pV P                  \        V P                  4      \        V4      4       V P                  R\        V4      4       R# )zd
If the message passed to L{callDeprecated} doesn't match,
L{callDeprecated} raises a test failure.
zsomething.wrongzplease use newMethod insteadN)r   rS   r  r  r  ry   r   r   r?  s   & r   $test_callDeprecationWithWrongMessage8CallDeprecatedTests.test_callDeprecationWithWrongMessage:  sj    
 %%!!\\,-
	 	&t||4c)nE4c)nEr   r6   N)r'   r(   r)   r*   r7   r   r  r  r  r  r  r  r  r  r,   r-   r.   s   @r   r  r    sK      iAq)GR(RJ Y.OF Fr   r  c                    V # )z 
Deprecated method for testing.
r6   r   s   &r   r  r  J  s	    
 Hr   r  )replacementc                    ^V ,          # )z\
Another deprecated method, which has been deprecated in favor of the
mythical 'newMethod'.
r6   r  s   &r   r  r  R  s     q5Lr   c                   R   a  ] tR tRt o Rt]! R^^^4      tR tR tR t	R t
RtV tR	# )
!GetDeprecatedModuleAttributeTestsi[  z
Test L{SynchronousTestCase.getDeprecatedModuleAttribute}

@ivar version: The version at which L{test_assertions.somethingOld}
    is marked deprecated.
@type version: L{incremental.Version}
Barc                    V P                  \        V P                  \        RV P                  4      4       V P                  . V P                  4       4       R# )zv
L{getDeprecatedModuleAttribute} returns the specified attribute and
consumes the deprecation warning that generates.
somethingOldNr   _somethingOldgetDeprecatedModuleAttributer'   r  rT   r  r$   s   &r   test_deprecated1GetDeprecatedModuleAttributeTests.test_deprecatedf  sI    
 	--	
 	T//12r   c           
         V P                  \        V P                  \        RV P                  RR7      4       V P                  . V P                  4       4       R# )zk
The I{message} argument to L{getDeprecatedModuleAttribute} matches the
prefix of the deprecation message.
r  zIt's old)r   Nr  r$   s   &r   test_message.GetDeprecatedModuleAttributeTests.test_messageu  sQ    
 	--"	 . 	
 	T//12r   c                    V P                  V P                  V P                  \        RV P                  R4       V P                  . V P                  4       4       R# )zp
L{getDeprecatedModuleAttribute} fails the test if the I{message} isn't
part of the deprecation message prefix.
r  zIt's shiny and newN)r   rS   r  r'   r  rT   r  r$   s   &r   test_messageMismatch6GetDeprecatedModuleAttributeTests.test_messageMismatch  sO    
 	!!--LL 	
 	T//12r   c                t    V P                  V P                  V P                  \        RV P                  4       R# )zn
L{getDeprecatedModuleAttribute} fails the test when used to get an
attribute that isn't actually deprecated.
somethingNewN)r   rS   r  r'   r  r$   s   &r   test_notDeprecated4GetDeprecatedModuleAttributeTests.test_notDeprecated  s1    
 	!!--LL	
r   r6   N)r'   r(   r)   r*   r7   r   r  r  r  r  r  r,   r-   r.   s   @r   r  r  [  s5      eQ1%G33 3
 
r   r  c                     R# )z^
A deprecated module attribute. Used by
L{GetDeprecatedModuleAttributeTests.test_deprecated}.
Nr6   r6   r   r   r  r        r   zIt's old and clunkyr  c                     R# )zm
A module attribute that is not deprecated. Used by
L{GetDeprecatedModuleAttributeTests.test_notDeprecated}.
Nr6   r6   r   r   r  r    r  r   ),r7   r   rF   rx  incrementalr   r   twisted.internet.deferr   r   r   twisted.python.deprecater   r   twisted.python.failurer	   twisted.python.reflectr
   r   r   twisted.python.utilr   twisted.trialr   r0   r   r;   rc   re   r   r   rp  r  r7  r~  r  r  r  r  r  r  r  r'   r  r6   r   r   <module>r     s  	   1 : : J * 
 - ",< ,	 	3;v 3;lJ0x33 J0ZJ.h22 J.ZI
!=!= I
Xm4H88 m4`^8h:: ^8BS8x'C'C S8l*B(66 *BZ`F(66 `FF ''( ) ''[A BD
(D(D D
N  %--	r   