ϪfdZddlZddlZddlmZmZddlmZm Z m Z ddl m Z m Z ddlmZddlmZmZmZddlmZdd lmZGd d eZGd d ZGddej2ZGddej6ZGddej6ZGddej6ZGddej6ZGddej6Z Gddej6Z!Gddej6Z"Gddej6Z#e e#jHd Z%e e#jHd!"d#Z&Gd$d%ej6Z'd&Z(e(Z)e e'jHd'e*d(d)Z+y)*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)VersiongetVersionString)Deferredfailsucceed) deprecateddeprecatedModuleAttribute)Failure)accumulateMethodsfullyQualifiedNameprefixedMethods) FancyEqMixin)unittestc"eZdZdZdZdefdZy) MockEqualitynamec||_yNr)selfrs D/usr/lib/python3/dist-packages/twisted/trial/test/test_assertions.py__init__zMockEquality.__init__$s  returnc"d|jdS)Nz MockEquality()rrs r__repr__zMockEquality.__repr__'styyk++rN)__name__ __module__ __qualname__compareAttributesrstrrrrrr!s!,#,rrceZdZdZdZeZeZy)ComparisonErrorzH An object which raises exceptions from its comparison methods. ctd)NzComparison is broken) ValueError)rothers r_errorzComparisonError._error0s/00rN)rr r!__doc__r*__eq____ne__r$rrr&r&+s1F Frr&cLeZdZdZGddej ZdZdZdZ y)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. ceZdZdZy)TestFailureTests.FailingTestc&|jdy)NzThis test fails.rrs r test_failsz'TestFailureTests.FailingTest.test_failsDs II( )rN)rr r!r4r$rr FailingTestr1Cs *rr5c0t|jj|jjg}tj|_|j j dj||_t|jd|_ y)zo Load a suite of one test which can be used to exercise the failure handling behavior. .rN) r __class__r5pyunit TestLoaderloaderloadTestsFromNamejoinsuitelisttest)r componentss rsetUpzTestFailureTests.setUpGsj  7 79I9I9R9RS '') [[22388J3GH $Q' rc |jjd|jdy#|jj$r%}|jdt |Yd}~yd}~wwxYw)z} L{SynchronousTestCase.fail} raises L{SynchronousTestCase.failureException} with the given argument. failedzRSynchronousTestCase.fail method did not raise SynchronousTestCase.failureExceptionN)r@rfailureException assertEqualr#rresults r test_failzTestFailureTests.test_failQs]   IINN8 $ II7 yy)) 4   Xs6{ 3 3 4s/A-A((A-cztj}|jj||j |j |j |jg|j t|jd|j |jdd|jy)z When a test method raises L{SynchronousTestCase.failureException}, the test is marked as having failed on the L{TestResult}. rN) r9 TestResultr>run assertFalse wasSuccessfulrFerrorslenfailuresr@rGs rtest_failingExceptionFailsz+TestFailureTests.test_failingExceptionFails`s ""$ v --/0 + V__-q1 +A. :rN) rr r!r+rSynchronousTestCaser5rBrIrSr$rrr/r/7s( *h22*(  ;rr/c4eZdZdZdZdZdZdZdZdZ y) 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}. cjdddddgfD](}||d|}||k7s|jd|*y)z Perform the positive case test for C{failIf} or C{assertFalse}. @param method: The test method to test. rFNr$ failed on Did not return argument r3)rmethodnotTruerHs r_assertFalseFalsez"AssertFalseTests._assertFalseFalsexsQ 3tR4 BGGz'%=>F  4WK@A Brc dddddgdfD]1} ||d||jd|jd|d 3y #|j$r/}|jd|t |d |d |Yd }~nd }~wwxYw) z Perform the negative case test for C{failIf} or C{assertFalse}. @param method: The test method to test. rKTcatrYCall to ( ) didn't failRaised incorrect exception on : NrrrEassertInr#)rr[truees r_assertFalseTruez!AssertFalseTests._assertFalseTrues eaVV4 D tz$23  ((   )F4THBqeD s ?A=%A88A=c:|j|jy)zt L{SynchronousTestCase.failIf} returns its argument if its argument is not considered true. N)r]failIfrs rtest_failIfFalsez!AssertFalseTests.test_failIfFalses t{{+rc:|j|jy)zy L{SynchronousTestCase.assertFalse} returns its argument if its argument is not considered true. N)r]rNrs rtest_assertFalseFalsez&AssertFalseTests.test_assertFalseFalses t//0rc:|j|jy)z L{SynchronousTestCase.failIf} raises L{SynchronousTestCase.failureException} if its argument is considered true. N)rmrors rtest_failIfTruez AssertFalseTests.test_failIfTrues dkk*rc:|j|jy)z L{SynchronousTestCase.assertFalse} raises L{SynchronousTestCase.failureException} if its argument is considered true. N)rmrNrs rtest_assertFalseTruez%AssertFalseTests.test_assertFalseTrues d../rN) rr r!r+r]rmrprrrtrvr$rrrVrVms& B0,1+0rrVc4eZdZdZdZdZdZdZdZdZ y) 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 dddddgfD]1} ||d||jd|jd|d 3y#|j$r/}|jd|t |d |d |Yd}~nd}~wwxYw) z Perform the negative case test for C{assertTrue} and C{failUnless}. @param method: The test method to test. rrXFNr$rYrdrerfrgrhri)rr[r\rls r_assertTrueFalsez AssertTrueTests._assertTrueFalses 3tR4 G w*WK 89  ((    ,F4WKr!G s >A< %A77A<cldddddgdfD](}||d|}||k7s|jd|*y) z Perform the positive case test for C{assertTrue} and C{failUnless}. @param method: The test method to test. rKTr_r`rarYrZNr3)rr[rkrHs r_assertTrueTruezAssertTrueTests._assertTrueTruesP eaVV4 ?DDJth"78F~ 4TH=> ?rc:|j|jy)z L{SynchronousTestCase.assertTrue} raises L{SynchronousTestCase.failureException} if its argument is not considered true. N)rz assertTruers rtest_assertTrueFalsez$AssertTrueTests.test_assertTrueFalse doo.rc:|j|jy)z L{SynchronousTestCase.failUnless} raises L{SynchronousTestCase.failureException} if its argument is not considered true. N)rz failUnlessrs rtest_failUnlessFalsez$AssertTrueTests.test_failUnlessFalserrc:|j|jy)zt L{SynchronousTestCase.assertTrue} returns its argument if its argument is considered true. N)r|r~rs rtest_assertTrueTruez#AssertTrueTests.test_assertTrueTrue T__-rc:|j|jy)zt L{SynchronousTestCase.failUnless} returns its argument if its argument is considered true. N)r|rrs rtest_failUnlessTruez#AssertTrueTests.test_failUnlessTruerrN) rr r!r+rzr|rrrrr$rrrxrxs%0 ?//..rrxc8eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+e,e-j\d*d+d,e+_/y+y+)-SynchronousAssertionsTestsa 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. cV|j||}||k7r|jdyy)Nz)assertEqual should return first parameter)rFr)rfirstsecondxs r_testEqualPairz)SynchronousAssertionsTests._testEqualPairs-   UF + : IIA B rcd} |j|||s|j d|d|d yy#|j$r}tjd} |j||nP#|j$r>}d}t |}t |}||k7r|j d|d|Yd}~nd}~wwxYwYd}~d}~wwxYw) 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. FrBTz Expected: z; Got: NzCall to assertEqual(, rf)rFrEr9TestCaser#r) rrrraised ourFailurecase theirFailuregotexpecteds r_testUnequalPairz+SynchronousAssertionsTests._testUnequalPairs  G   UF + II,UIRzO P$$ G??7+D G  /(( G*o|,s?II 8,gcWEF  G Gs?2CB?A*)B?*B794B2-B?2B77B??Cc|jdd|jdd|jdgdg|jdgdy)Nr_dogrKorange)rrrs rtest_assertEqual_basicz1SynchronousAssertionsTests.test_assertEqual_basic/sH E5) eU+ QC!% qc8,rctd}td}td}|j|||j|||j|||j||y)Nrr)rrr)rryzs rtest_assertEqual_customz2SynchronousAssertionsTests.test_assertEqual_custom5s`  !  "  ! Aq! Aq! a# a#rcd}|j|j|jdd|}|j|t |y)zi When a message is passed to L{assertEqual} it is included in the error message. messagefoobarN) assertRaisesrErFrjr#)rr exceptions rtest_assertEqualMessagez2SynchronousAssertionsTests.test_assertEqualMessage>sD %%  ! !4#3#3UE7  gs9~.rc|j|j|jddd}|j|j|jdd}|jt|t|y)zz If a message is specified as L{None}, it is not included in the error message of L{assertEqual}. rrN)rrErFr#)rexceptionForNoneexceptionWithouts rtest_assertEqualNoneMessagez6SynchronousAssertionsTests.test_assertEqualNoneMessageIsr  ,,  ! !4#3#3UE4  ,,  ! !4#3#3UE  -.4D0EFrct}dg} |j|||jdj||y#|j$r|jdYyt $rYywxYw)Nrz7Comparing {!r} and {!r} should have raised an exceptionz6Fail raised when ValueError ought to have been raised.)r&rFrformatrEr()rapplers rtest_assertEqual_incomparablez8SynchronousAssertionsTests.test_assertEqual_incomparableVsw!    UF + IIIPP6  $$ P IIN O   sA A0%A0/A0c|rr$)rerrors r _raiseErrorz&SynchronousAssertionsTests._raiseErrorgs rc|jt|jt}|jt |tdy)Nz?Expect failUnlessRaises to return instance of raised exception.)failUnlessRaisesr(rr~ isinstancerrs rtest_failUnlessRaises_expectedz9SynchronousAssertionsTests.test_failUnlessRaises_expectedjs5  ! !*d.>.> K  q* % P rc |jt|jt|j dy#t$r|j dYy|j $rYywxYw)Nz4Expected exception wasn't raised. Should have failedz9failUnlessRaises shouldn't re-raise unexpected exceptions)rr(r TypeErrorrrErs r test_failUnlessRaises_unexpectedz;SynchronousAssertionsTests.test_failUnlessRaises_unexpectedqs_ N  ! !*d.>.> J IIL M  V IIT U$$   s%9A&A&%A&cd |jtfd|jdy#|j$r%}|j t |dYd}~yd}~wwxYw)NrbcSrr$) returnValuesrzNSynchronousAssertionsTests.test_failUnlessRaises_noException..skrz(Exception not raised. Should have failedz"ValueError not raised (3 returned))rr(rrErFr#)rrlrs @r!test_failUnlessRaises_noExceptionzSynchronousAssertionsTests.test_assertRaisesContextNoExceptionsu O"":.   IIM N  $$ O)nG   W&M N N  Os%?3?<?A5A00A5c |jttf5t#1swYnxYw |j dy#|j $rp}t |}d|v}d|v}g}|r|jd|r|jd|r)|j dj|d|Yd}~yYd}~yd}~wwxYw) 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. Nrr(rz(expected ValueError in exception messagez'expected TypeError in exception messagez; z message = ) rr(rAttributeErrorrrEr#appendr=)rrr valueError typeErrorrPs rtest_brokenNamez*SynchronousAssertionsTests.test_brokenNames  T""J #:; '$&& ' ' ' IIR S$$ E)nG%W4J#72IF HI GH $))F+z'-CDD Es%A (1ACA!CCcdgdgdg}}}|j||}|j||d|j|j|j|||j|j|j||y)NrKr`)failIfEqual should return first parameter) failIfEqualrFrrErrrrrets rtest_failIfEqual_basicz1SynchronousAssertionsTests.test_failIfEqual_basicsz#sQCa1q!$ a!LM d33T5E5Eq!L d33T5E5Eq!Lrctd}td}td}|j||}|j||d|j|j|j|||j||dy)Nrrfecundrz"__ne__ should make these not equal)rrrFrrErs rtest_failIfEqual_customEqz4SynchronousAssertionsTests.test_failIfEqual_customEqsx  !  "  "q!$ a!LM d33T5E5Eq!L ACDrctt}t}|j||}|j||y)z C{failIfIdentical} returns its first argument if its first and second arguments are not the same object. N)objectfailIfIdenticalrF)rrrrHs rtest_failIfIdenticalPositivez7SynchronousAssertionsTests.test_failIfIdenticalPositives4 H H%%a+ F#rcht}|j|j|j||y)z~ C{failIfIdentical} raises C{failureException} if its first and second arguments are the same object. N)rrrErrs rtest_failIfIdenticalNegativez7SynchronousAssertionsTests.test_failIfIdenticalNegatives+ H d33T5I5I1aPrcdgdgdg}}}|j||}|j||d|j|j|j|||j|j|j||y)NrKr`z1failUnlessIdentical should return first parameter)failUnlessIdenticalrFrrErs rtest_failUnlessIdenticalz3SynchronousAssertionsTests.test_failUnlessIdenticals|#sQCa1&&q!, a!WX d33T5M5MqRST d33T5M5MqRSTrc&d\}}}|j||d|j||d}|j||d|j|j|j||d|j|j|j||dy)N)g?g?g333333?g?z4failUnlessApproximates should return first parameterg?)failUnlessApproximatesrFrrErs rtest_failUnlessApproximatesz6SynchronousAssertionsTests.test_failUnlessApproximatess1a ##Aq#.))!Q4  M    ! !4#>#>1c    ! !4#>#>1c rc d}d}d}d}|j||||j|||}|j||d|d|d|j|j|j|||y)NA! @XO @C @z5failUnlessAlmostEqual should return first parameter (rr)failUnlessAlmostEqualrFrrEr precisionrrrrs rtest_failUnlessAlmostEqualz5SynchronousAssertionsTests.test_failUnlessAlmostEquals    ""1a3((Ay9   *-q 2   ! !4#=#=q!Y rc d}d}d}d}|j|||}|j||d|d|d|j|j|j||||j|j|j|||y)Nrrrrz1failIfAlmostEqual should return first parameter (rr)failIfAlmostEqualrFrrErs rtest_failIfAlmostEqualz1SynchronousAssertionsTests.test_failIfAlmostEqual.s   $$Q95   MPRS T   ! !4#9#91a    ! !4#9#91a rcd}d}d}|j|||j||}|j||d|j|j|j|||j|j|j||yNr_z the dog satz the cat satzshould return first parameter)failUnlessSubstringrFrrErs rtest_failUnlessSubstringz3SynchronousAssertionsTests.test_failUnlessSubstring@s      A&&&q!, a!@A d33T5M5MqRST d33T5M5MqRSTrcd}d}d}|j|||j||}|j||d|j|j|j|||j|j|j||yr)failIfSubstringrFrrErs rtest_failIfSubstringz/SynchronousAssertionsTests.test_failIfSubstringJs    Q"""1a( a!@A d33T5I5I1aP d33T5I5I1aPrc>td}|j||y)zB L{assertIs} passes if two objects are identical. rN)rrras r test_assertIsz(SynchronousAssertionsTests.test_assertIsTs  ! arctdtd}}|j|||j|j|j||y)zE L{assertIs} fails if two objects are not identical. rN)rrFrrErrrbs rtest_assertIsErrorz-SynchronousAssertionsTests.test_assertIsError[sEG$l7&;1 A $//1Ercxtdtd}}|j|||j||y)zI L{assertIsNot} passes if two objects are not identical. rN)rrF assertIsNotrs rtest_assertIsNotz+SynchronousAssertionsTests.test_assertIsNotcs7G$l7&;1 A Arcjtd}|j|j|j||y)zD L{assertIsNot} fails if two objects are identical. rN)rrrErrs rtest_assertIsNotErrorz0SynchronousAssertionsTests.test_assertIsNotErrorks.  ! $//1A1A1aHrcZtdtfi}|}|j||y)z< Test a true condition of assertIsInstance. ANrrassertIsInstance)rr rs rtest_assertIsInstancez0SynchronousAssertionsTests.test_assertIsInstancers+ vi $ C a#rctdtfi}tdtfi}|}|j|||fy)zR Test a true condition of assertIsInstance with multiple classes. r BNr rr rrs r$test_assertIsInstanceMultipleClassesz?SynchronousAssertionsTests.test_assertIsInstanceMultipleClasseszs? vi $ vi $ C a!Q(rctdtfi}tdtfi}|}|j|j|j||y)z6 Test an error with assertIsInstance. r rNrrrrEr rs rtest_assertIsInstanceErrorz5SynchronousAssertionsTests.test_assertIsInstanceErrorsK vi $ vi $ C $//1F1F1Mrctdtfi}tdtfi}tdtfi}|}|j|j|j|||fy)zK Test an error with assertIsInstance and multiple classes. r rCNrrr rrrs r)test_assertIsInstanceErrorMultipleClasseszDSynchronousAssertionsTests.test_assertIsInstanceErrorMultipleClassess_ vi $ vi $ vi $ C $//1F1FAq6Rrc|j|j|jdtd}|j dt|y)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. rbzSilly assertionN)rrEr r#rj)rexcs r"test_assertIsInstanceCustomMessagez=SynchronousAssertionsTests.test_assertIsInstanceCustomMessagesA   ! !4#8#8!SBS  'S2rc~tdtfi}tdtfi}|}|j||y)z? Test a true condition of assertNotIsInstance. r rNrrassertNotIsInstancers rtest_assertNotIsInstancez3SynchronousAssertionsTests.test_assertNotIsInstances; vi $ vi $ C   A&rctdtfi}tdtfi}tdtfi}|}|j|||fy)zT Test a true condition of assertNotIsInstance and multiple classes. r rrNrrs r'test_assertNotIsInstanceMultipleClasseszBSynchronousAssertionsTests.test_assertNotIsInstanceMultipleClassessO vi $ vi $ vi $ C   QF+rctdtfi}|}|j|j|j||}|j t ||d|y)z9 Test an error with assertNotIsInstance. r z is an instance of N)rrrrErrFr#)rr rrs rtest_assertNotIsInstanceErrorz8SynchronousAssertionsTests.test_assertNotIsInstanceErrors_ vi $ C!!$"7"79Q9QSTVWX Uu,?s%CDrctdtfi}tdtfi}|}|j|j|j|||fy)zN Test an error with assertNotIsInstance and multiple classes. r rN)rrrrErrs r,test_assertNotIsInstanceErrorMultipleClasseszGSynchronousAssertionsTests.test_assertNotIsInstanceErrorMultipleClassessP vi $ vi $ C $//1I1I1qRSfUrc0|jddiddiy)z L{twisted.trial.unittest.TestCase} supports the C{assertDictEqual} method inherited from the standard library in Python 2.7. rrKN)assertDictEqualrs rtest_assertDictEqualz/SynchronousAssertionsTests.test_assertDictEquals c1XQx0rr(Nz:assertDictEqual is not available on this version of Python)0rr r!r+rrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrr r"r$r&r)getattrrrTskipr$rrrrs  C Q.- $ / G"  NB6$ 4T.O$T0ME$QU   " $UQFI$)NS 3',EV1x++->EM H !NrrcZeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd Zy)WarningAssertionTestschd}|jtdt|d}|j|dy)z0 Test basic assertWarns report. c<tjdt|SNWoo deprecatedcategorywarningswarnDeprecationWarningrs rrz:WarningAssertionTests.test_assertWarns..deprecated MM*5G HHrr1{N assertWarnsr7__file__rFrrrs rtest_assertWarnsz&WarningAssertionTests.test_assertWarnss7       0(J  C rcd}|jtdt|d}|j|d|jtdt|d}|j|dy)z} Test that assertWarns cleans the warning registry, so the warning is not swallowed the second time. c<tjdt|Sr0r4r8s rrzGWarningAssertionTests.test_assertWarnsRegistryClean..deprecatedr9rr1r:ANr;)rrr1r2s rtest_assertWarnsRegistryCleanz3WarningAssertionTests.test_assertWarnsRegistryCleanse      0(J  S!     0(J  S!rc pd}|j|j|jtdt|dy)zH Test assertWarns failure when no warning is generated. c|Srr$r8s rnormalz;WarningAssertionTests.test_assertWarnsError..normalsHrr1r:NrrEr<r7r=)rrIs rtest_assertWarnsErrorz+WarningAssertionTests.test_assertWarnsErrors8     ! !         rc pd}|j|j|jtdt|dy)zF Test assertWarns failure when the category is wrong. c<tjdt|SNFoo deprecatedr2r4r8s rrzGWarningAssertionTests.test_assertWarnsWrongCategory..deprecated r9rrOr:N)rrEr< UserWarningr=rrs rtest_assertWarnsWrongCategoryz3WarningAssertionTests.test_assertWarnsWrongCategorys8     ! !         rc pd}|j|j|jtdt|dy)zE Test assertWarns failure when the message is wrong. c<tjdt|SrNr4r8s rrzFWarningAssertionTests.test_assertWarnsWrongMessage..deprecated r9rBar deprecatedr:NrJrQs rtest_assertWarnsWrongMessagez2WarningAssertionTests.test_assertWarnsWrongMessages8     ! !         rc pd}|j|j|jtdt|dy)z If the warning emitted by a function refers to a different file than is passed to C{assertWarns}, C{failureException} is raised. c<tjdtdy)NrOr`)r3 stacklevelr4r8s rrzCWarningAssertionTests.test_assertWarnsWrongFile..deprecated4s MM*5GTU VrrOr:NrJrQs rtest_assertWarnsWrongFilez/WarningAssertionTests.test_assertWarnsWrongFile.s; W   ! !         rcGdd}|jtdt|}|jt |||jtdt|}|jt ||y)zH Test assertWarns works when creating a class instance. ceZdZdZy);WarningAssertionTests.test_assertWarnsOnClass..Warnc:tjdty)NDo not call mer2)r5r6RuntimeWarningrs rrzDWarningAssertionTests.test_assertWarnsOnClass..Warn.__init__Ss .HrN)rr r!rr$rrWarnr]Rs Irrar_N)r<r`r=r~r)rrar?s rtest_assertWarnsOnClassz-WarningAssertionTests.test_assertWarnsOnClassMsd  I I   ^-=x N  1d+,   ^-=x N  1d+,rc Gdd}|}|jtdt|jd}|j |d|jtdt|jd}|j |dy)zI Test assertWarns works when used on an instance method. ceZdZdZy).Warnc<tjdt|S)NrUr2r4rs rrzGWarningAssertionTests.test_assertWarnsOnMethod..Warn.deprecateda .9KLrN)rr r!rr$rrrare` rrarUrCN)r<r7r=rrFrrawr?s rtest_assertWarnsOnMethodz.WarningAssertionTests.test_assertWarnsOnMethod[sy    F     0(ALL#  C     0(ALL#  C rcGdd}|}|jtdt|d}|j|d|jtdt|d}|j|dy)zM Test assertWarns works on instance with C{__call__} method. ceZdZdZy):WarningAssertionTests.test_assertWarnsOnCall..Warnc<tjdt|S)NEgg deprecatedr2r4rs r__call__zCWarningAssertionTests.test_assertWarnsOnCall..Warn.__call__urgrN)rr r!rqr$rrrarntrhrrarprCNr;ris rtest_assertWarnsOnCallz,WarningAssertionTests.test_assertWarnsOnCallosk    F   /1A8QPS T C   /1A8QPS T C rchd}|jtdt|d}|j|dy)zD Test assertWarns on a warning filtered by default. c<tjdt|Sr0r5r6PendingDeprecationWarningr8s rrz@WarningAssertionTests.test_assertWarnsFilter..deprecateds MM*5N OHrr1r:N)r<rvr=rFr>s rtest_assertWarnsFilterz,WarningAssertionTests.test_assertWarnsFilters7      %'7:s  C rcNdfd}|jtdt|y)z C{assertWarns} does not raise an exception if the function it is passed triggers the same warning more than once. c:tjdtyr0rur$rrrzJWarningAssertionTests.test_assertWarnsMultipleWarnings..deprecateds MM*5N Orc"yrr$)rsrfzAWarningAssertionTests.test_assertWarnsMultipleWarnings..fs L Lrr1N)r<rvr=)rr{rs @r test_assertWarnsMultipleWarningsz6WarningAssertionTests.test_assertWarnsMultipleWarningss'  P  24DhPQRrc d}|j|j|jtdt|d}|j t |dy)z For now, assertWarns is unable to handle multiple different warnings, so it should raise an exception if it's the case. cptjdttjdty)Nr1r2z Another one)r5r6r7rvr8s rrzKWarningAssertionTests.test_assertWarnsDifferentWarnings..deprecateds! MM*5G H MM-2K Lrr1r:zCan't handle different warningsN)rrEr<r7r=rFr#)rrrls r!test_assertWarnsDifferentWarningsz7WarningAssertionTests.test_assertWarnsDifferentWarningssR  M     ! !          Q!BCrcGddtfd}|d|jdt|d|j|g\}|j |ddy)z Warnings emitted before L{TestCase.assertWarns} is called do not get flushed and do not alter the behavior of L{TestCase.assertWarns}. c eZdZy)PWarningAssertionTests.test_assertWarnsAfterUnassertedWarning..TheWarningN)rr r!r$rr TheWarningrs rrc4tj|y)Nr2)r5r6)rrs rr{zGWarningAssertionTests.test_assertWarnsAfterUnassertedWarning..fs MM'J 7rrrrN)Warningr<r= flushWarningsrF)rr{warningrs @r&test_assertWarnsAfterUnassertedWarningz -!(! ! SD*4rr-ceZdZdZeZeedZdZ dZ dZ dZ dZ dZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZy)ResultOfAssertionsTestsz Tests for L{SynchronousTestCase.successResultOf}, L{SynchronousTestCase.failureResultOf}, and L{SynchronousTestCase.assertNoResult}. Bad timescb|j|j|jty)z L{SynchronousTestCase.successResultOf} raises L{SynchronousTestCase.failureException} when called with a L{Deferred} with no current result. N)rrEsuccessResultOfrrs rtest_withoutResultz*ResultOfAssertionsTests.test_withoutResult$ $//1E1ExzRrcx|j|j|jt|jy)z L{SynchronousTestCase.successResultOf} raises L{SynchronousTestCase.failureException} when called with a L{Deferred} with a failure result. N)rrErrfailurers rtest_successResultOfWithFailurez7ResultOfAssertionsTests.test_successResultOfWithFailures.   ! !4#7#7dll9K rc |jt|jy#|j$r=}|j |jj t |Yd}~yd}~wwxYw)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)rrrrErj getTracebackr#rrls r+test_successResultOfWithFailureHasTracebackzCResultOfAssertionsTests.test_successResultOfWithFailureHasTracebacksV  ?  dll!3 4$$ ? MM$,,335s1v > > ?s$'A33A..A3cb|j|j|jty)z L{SynchronousTestCase.failureResultOf} raises L{SynchronousTestCase.failureException} when called with a L{Deferred} with no current result. N)rrEfailureResultOfrrs r!test_failureResultOfWithoutResultz9ResultOfAssertionsTests.test_failureResultOfWithoutResultrrcx|j|j|jt|jy)z L{SynchronousTestCase.failureResultOf} raises L{SynchronousTestCase.failureException} when called with a L{Deferred} with a success result. N)rrErrrHrs rtest_failureResultOfWithSuccessz7ResultOfAssertionsTests.test_failureResultOfWithSuccesss.   ! !4#7#79M rc|j|j|jt|jt y)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)rrErrrKeyErrorrs r$test_failureResultOfWithWrongFailurez$$  MM5<<''):):A    s),B ABB c |jt|jty#|j$r=}|j |jj t|Yd}~yd}~wwxYw)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)rrrrrErjrr#rs r;test_failureResultOfWithWrongFailureOneExpectedFailureHasTBzSResultOfAssertionsTests.test_failureResultOfWithWrongFailureOneExpectedFailureHasTBsX ?  dll!3X >$$ ? MM$,,335s1v > > ?s),A83A33A8c d |jt|jtty#|j $ro}|j djtjtjtjtjt|Yd}~yd}~wwxYw)aH 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) rrrrIOErrorrErjrr rr#rs r9test_failureResultOfWithWrongFailureMultiExpectedFailureszQResultOfAssertionsTests.test_failureResultOfWithWrongFailureMultiExpectedFailures%s   dll!3Xw G$$  MM>EE''%%&&$$  A   s.1B/A%B**B/c |jt|jtty#|j $r=}|j |jjt|Yd}~yd}~wwxYw)aJ 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) rrrrrrErjrr#rs r>test_failureResultOfWithWrongFailureMultiExpectedFailuresHasTBzVResultOfAssertionsTests.test_failureResultOfWithWrongFailureMultiExpectedFailuresHasTB:sZ ?  dll!3Xw G$$ ? MM$,,335s1v > > ?s.1A=3A88A=c|j|j|jt|jy)a 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)assertIdenticalrHrrrs r%test_successResultOfWithSuccessResultz=ResultOfAssertionsTests.test_successResultOfWithSuccessResultGs, T[[$*>*>wt{{?S*TUrc|j|j|jt|j|jjt y)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)rrrrrrrs r-test_failureResultOfWithExpectedFailureResultzEResultOfAssertionsTests.test_failureResultOfWithExpectedFailureResultPs>  LL  dll!3T\\5F5F Q rc|j|j|jt|jy)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}. N)rrrrrs r%test_failureResultOfWithFailureResultz=ResultOfAssertionsTests.test_failureResultOfWithFailureResult\s, T\\4+?+?T\\@R+STrcx|j|j|jt|jy)z When passed a L{Deferred} which currently has a success result (see L{test_withSuccessResult}), L{SynchronousTestCase.assertNoResult} raises L{SynchronousTestCase.failureException}. N)rrEassertNoResultrrHrs rtest_assertNoResultSuccessz2ResultOfAssertionsTests.test_assertNoResultSuccesses.   ! !4#6#6 8L rcx|j|j|jt|jy)z When passed a L{Deferred} which currently has a failure result (see L{test_withFailureResult}), L{SynchronousTestCase.assertNoResult} raises L{SynchronousTestCase.failureException}. N)rrErrrrs rtest_assertNoResultFailurez2ResultOfAssertionsTests.test_assertNoResultFailureos.   ! !4#6#6T\\8J rc6|jty)z When passed a L{Deferred} with no current result, L{SynchronousTestCase.assertNoResult} does not raise an exception. N)rrrs rtest_assertNoResultz+ResultOfAssertionsTests.test_assertNoResultys HJ'rct}|j||j|j|j |j|j |y)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}. NrrcallbackrHrFrrds r$test_assertNoResultPropagatesSuccesszrct}|j||j|j|j |j|j |y)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)rrerrbackrrFrrs r)test_assertNoResultPropagatesLaterFailurezAResultOfAssertionsTests.test_assertNoResultPropagatesLaterFailuresH J A $,, t';';A'>?rct|j} |j||j d|j |y#|j$rY3wxYw) 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. NrrrrErFrrs r+test_assertNoResultSwallowsImmediateFailurezCResultOfAssertionsTests.test_assertNoResultSwallowsImmediateFailures\       " t33A67$$   sA AAN)rr r!r+rrHr Exceptionrrrrrrrrrrrrrrrrrrrrr$rrrrs XFi ,-GS  ?S  $ ?* ?V  U  ( ? @ 8rrceZdZdZeZedZeeZ dZ dZ ddZ dZ dZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZy) ResultOfCoroutineAssertionsTestsz Tests for L{SynchronousTestCase.successResultOf}, L{SynchronousTestCase.failureResultOf}, and L{SynchronousTestCase.assertNoResult} when given a coroutine. rc"K|jSwr)rHrs r successResultz.ResultOfCoroutineAssertionsTests.successResults{{s c4Ktd{y7wr)rrs rnoCurrentResultz0ResultOfCoroutineAssertionsTests.noCurrentResultsjs Nc*K| |j}|wr)rrrs rraisesExceptionz0ResultOfCoroutineAssertionsTests.raisesExceptions  Iscn|j|j|j|jy)z L{SynchronousTestCase.successResultOf} raises L{SynchronousTestCase.failureException} when called with a coroutine with no current result. N)rrErrrs rrz3ResultOfCoroutineAssertionsTests.test_withoutResult.   ! !4#7#79M9M9O rcn|j|j|j|jy)z L{SynchronousTestCase.successResultOf} raises L{SynchronousTestCase.failureException} when called with a coroutine that raises an exception. N)rrErrrs r!test_successResultOfWithExceptionzBResultOfCoroutineAssertionsTests.test_successResultOfWithExceptionrrctd} |j|j|y#|j$r@}|j dt ||j dt |Yd}~yd}~wwxYw)z L{SynchronousTestCase.successResultOf} raises a L{SynchronousTestCase.failureException} that has the original failure traceback when called with a coroutine with a failure result. rzSuccess result expected onbuiltins.Exception: Bad timesN)rrrrErjr#rrrls rrzLResultOfCoroutineAssertionsTests.test_successResultOfWithFailureHasTracebacksn k*  C  !5!5i!@ A$$ C MM6A ? MM93q6 B B Cs .A=6A88A=cn|j|j|j|jy)z L{SynchronousTestCase.failureResultOf} raises L{SynchronousTestCase.failureException} when called with a coroutine with no current result. N)rrErrrs rrzBResultOfCoroutineAssertionsTests.test_failureResultOfWithoutResultrrcn|j|j|j|jy)z L{SynchronousTestCase.failureResultOf} raises L{SynchronousTestCase.failureException} when called with a coroutine with a success result. N)rrErrrs rrz@ResultOfCoroutineAssertionsTests.test_failureResultOfWithSuccesss.   ! !4#7#79K9K9M rcx|j|j|j|jty)z L{SynchronousTestCase.failureResultOf} raises L{SynchronousTestCase.failureException} when called with a coroutine that raises an exception that was not expected. N)rrErrrrs rrzEResultOfCoroutineAssertionsTests.test_failureResultOfWithWrongFailures3   ! !   "   rc |j|jty#|j$rQ}|j dj tj tjt|Yd}~yd}~wwxYw)aF 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. rN) rrrrErjrr rr#rs r:test_failureResultOfWithWrongExceptionOneExpectedExceptionz[ResultOfCoroutineAssertionsTests.test_failureResultOfWithWrongExceptionOneExpectedExceptionso   !5!5!7 B$$  MM5<<''):):A    s$'BABBc td} |j|j|ty#|j$r@}|j dt ||j dt |Yd}~yd}~wwxYw)aK 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. rz/Failure of type (builtins.KeyError) expected onrN)rrrrrErjr#rs r?test_failureResultOfWithWrongExceptionOneExpectedExceptionHasTBz`ResultOfCoroutineAssertionsTests.test_failureResultOfWithWrongExceptionOneExpectedExceptionHasTBsqk*  C  !5!5i!@( K$$ C MMKSQRV T MM93q6 B B Cs%3B6A==Bc Z |j|jtty#|j$ro}|j dj tjtjtjtjt|Yd}~yd}~wwxYw)aN 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. rN) rrrrrErjrr rr#rs r=test_failureResultOfWithWrongExceptionMultiExpectedExceptionsz^ResultOfCoroutineAssertionsTests.test_failureResultOfWithWrongExceptionMultiExpectedExceptionss   !5!5!77 K$$  MM>EE''%%&&$$  A   s),B*A%B%%B*ctd} |j|j|tty#|j $r@}|j dt||j dt|Yd}~yd}~wwxYw)aV 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. rzCFailure of type (builtins.KeyError or builtins.OSError) expected onrN)rrrrrrErjr#rs rBtest_failureResultOfWithWrongExceptionMultiExpectedExceptionsHasTBzcResultOfCoroutineAssertionsTests.test_failureResultOfWithWrongExceptionMultiExpectedExceptionsHasTB2swk*  C  !5!5i!@(G T$$ C MMUA  MM93q6 B B  Cs*8B6BBcv|j|j|j|jy)a$ 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)rrHrrrs rrzFResultOfCoroutineAssertionsTests.test_successResultOfWithSuccessResultEs, T[[$*>*>t?Q?Q?S*TUrc|j|jj|j|j |jj t jy)ar 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)rFrvaluerrrrrs r)test_failureResultOfWithExpectedExceptionzJResultOfCoroutineAssertionsTests.test_failureResultOfWithExpectedExceptionNsL  LL    $$& (9(98 e  rc|j|jj|j|j jy)aW 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)rFrrrrrs r!test_failureResultOfWithExceptionzBResultOfCoroutineAssertionsTests.test_failureResultOfWithException]s;  LL   4 4T5I5I5K L R R rcn|j|j|j|jy)z When passed a coroutine which currently has a success result (see L{test_withSuccessResult}), L{SynchronousTestCase.assertNoResult} raises L{SynchronousTestCase.failureException}. N)rrErrrs rrz;ResultOfCoroutineAssertionsTests.test_assertNoResultSuccessis.   ! !4#6#68J8J8L rcn|j|j|j|jy)z When passed a coroutine which currently has an exception result (see L{test_withFailureResult}), L{SynchronousTestCase.assertNoResult} raises L{SynchronousTestCase.failureException}. N)rrErrrs rrz;ResultOfCoroutineAssertionsTests.test_assertNoResultFailuress.   ! !4#6#68L8L8N rcB|j|jy)z When passed a coroutine with no current result, L{SynchronousTestCase.assertNoResult} does not raise an exception. N)rrrs rrz4ResultOfCoroutineAssertionsTests.test_assertNoResult}s D0023rctfd}|}|jj|j|j |j|j |y)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$Kd{S7wrr$rsrrz^ResultOfCoroutineAssertionsTests.test_assertNoResultPropagatesSuccess..noCurrentResult7N7 Nr)rrcrs @rrzEResultOfCoroutineAssertionsTests.test_assertNoResultPropagatesSuccesssX J    A 4;; d&:&:1&=>rc t|j}tfd}|}|jj ||j |j |j|j y)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$Kd{S7wrr$rsrrzcResultOfCoroutineAssertionsTests.test_assertNoResultPropagatesLaterFailure..noCurrentResultrrN)r rrrrrFrr)rr{rrrs @rrzJResultOfCoroutineAssertionsTests.test_assertNoResultPropagatesLaterFailuresg DNN # J    A !  $"6"6q"9"?"?@rct|jfd}|} |j|j d|j |y#|j$rY3wxYw)rc$Kd{S7wrr$rsrrzeResultOfCoroutineAssertionsTests.test_assertNoResultSwallowsImmediateFailure..raisesExceptionrrNr)rrrrs @rrzLResultOfCoroutineAssertionsTests.test_assertNoResultSwallowsImmediateFailuresl          " t33A67$$   sAA)(A)r) rr r!r+rrHrrr rrrrrrrrrrrrrrrrrrrrrrrr$rrrrs XF+&Ii G    C    $ C*C&V      4?"A$8rrc.eZdZdZdZdZdZdZdZy)AssertionNamesTestszK Tests for consistency of naming within TestCase assertion methods ci}t||d|Dcgc]}|jdr|dk7s||!c}Scc}w)NassertNot_)r r)rdctks r _getAssertszAssertionNamesTests._getAssertss<$X. #L11<<+>18ALLLs ;;;c|jSr)rrs r_namezAssertionNamesTests._names zzrct|j}tt|d}|j||j |y)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. rN)setrr rF intersection)rasserts failUnlessess rtest_failUnlessMatchesAssertz0AssertionNamesTests.test_failUnlessMatchesAssertsCd&&()?4>?  w';';L'IJrcttjd}ttjd}|jt ||j t ||j y)N assertNotro)key)r rrTrFsortedr)rrfailIfss rtest_failIf_matches_assertNotz1AssertionNamesTests.test_failIf_matches_assertNotsO!(">"> L!(">">I  7 +VG-L rc t|jD]\}}t|s|jdrD|j t ||dz|d|d|j |t||dz|jdsy|j t ||dd|d|dd|j |t||ddy)NEqualsz but no Equals)varsitemscallableendswithr~hasattrrFr*)rrrs rtest_equalSpellingz&AssertionNamesTests.test_equalSpellings:++- BKD%E?}}W%dSj 9dV8D6QR;ST  dSj(AB}}X&d3Bi 8TF(4PSQS9+:VW  d3Bi(@A BrN) rr r!r+rrrr rr$rrrrs#M  K  BrrcPeZdZdZeddddZdZdZdZdZ d Z d Z d Z y ) CallDeprecatedTestsz\ Test use of the L{SynchronousTestCase.callDeprecated} method with version objects. Twistedrc|j|jtd|j|j gdy)zj callDeprecated calls a deprecated callable, suppressing the deprecation warning. rzNo warnings should be shownN)callDeprecatedversion oldMethodrFrrs r$test_callDeprecatedSuppressesWarningz8CallDeprecatedTests.test_callDeprecatedSuppressesWarnings6 DLL)U; ++-r3PQrcj|j|jtd}|jd|y)zn L{callDeprecated} actually calls the callable passed to it, and forwards the result. rN)rrrrFrGs r test_callDeprecatedCallsFunctionz4CallDeprecatedTests.test_callDeprecatedCallsFunctions, $$T\\9eD 'rcd}|j|j|j|j|}|j d|zt |y)zd L{callDeprecated} raises a test failure if the callable is not deprecated. cyrr$r$rr notDeprecatedzGCallDeprecatedTests.test_failsWithoutDeprecation..notDeprecateds rz%r is not deprecated.N)rrErrrFr#)rr#rs rtest_failsWithoutDeprecationz0CallDeprecatedTests.test_failsWithoutDeprecationsN  %%  ! !4#6#6 m  0=@#i.Qrctdddd}|j|j|j|td}|j t |jt||j t |t|y)z callDeprecated raises a test failure if the callable was deprecated at a different version to the one expected. FoorKr`rbrN) rrrErrrjrrr#)rdifferentVersionrs r"test_failsWithIncorrectDeprecationz6CallDeprecatedTests.test_failsWithIncorrectDeprecation sw #5!Q2%%  ! !         &t||4c)nE &'78#i.Irctdddd}d}t||}|j||d|j}|j t |dd|y) 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&rKr`rbct|Sr)r)argss rnestedDeprecationzECallDeprecatedTests.test_nestedDeprecation..nestedDeprecation&s d# #rzUnexpected warnings: N)rrrrrFrQ)rr'r, warningsShowns rtest_nestedDeprecationz*CallDeprecatedTests.test_nestedDeprecationss#5!Q2 $9J'789JK ,.?D **,  ]+Q2G 0WXrcJ|j|jdftdy)zj L{callDeprecated} can take a message argument used to check the warning emitted. newMethodrKN)rroldMethodReplacedrs rtest_callDeprecationWithMessagez3CallDeprecatedTests.test_callDeprecationWithMessage3s T\\;79JANrc|j|j|j|jdftd}|j t |jt||j dt|y)z| If the message passed to L{callDeprecated} doesn't match, L{callDeprecated} raises a test failure. zsomething.wrongrKzplease use newMethod insteadN)rrErrr2rjrr#rs r$test_callDeprecationWithWrongMessagez8CallDeprecatedTests.test_callDeprecationWithWrongMessage:sj %%  ! !    \\, -    &t||4c)nE 4c)nErN) rr r!r+rrrr r$r(r/r3r5r$rrrrsBiAq)GR( RJ Y.O Frrc|S)z( Deprecated method for testing. r$rs rrrJs Hrr1) replacementc d|zS)zh Another deprecated method, which has been deprecated in favor of the mythical 'newMethod'. r`r$r7s rr2r2Rs q5Lrc>eZdZdZeddddZdZdZdZd Z y ) !GetDeprecatedModuleAttributeTestsz Test L{SynchronousTestCase.getDeprecatedModuleAttribute} @ivar version: The version at which L{test_assertions.somethingOld} is marked deprecated. @type version: L{incremental.Version} BarrKr`rbc|jt|jtd|j|j g|j y)z L{getDeprecatedModuleAttribute} returns the specified attribute and consumes the deprecation warning that generates. somethingOldNr _somethingOldgetDeprecatedModuleAttributerrrFrrs rtest_deprecatedz1GetDeprecatedModuleAttributeTests.test_deprecatedfsI   - -    T//12rc |jt|jtd|jd|j g|j y)z The I{message} argument to L{getDeprecatedModuleAttribute} matches the prefix of the deprecation message. r>zIt's old)rNr?rs r test_messagez.GetDeprecatedModuleAttributeTests.test_messageusQ   - - " .   T//12rc|j|j|jtd|jd|j g|j y)z L{getDeprecatedModuleAttribute} fails the test if the I{message} isn't part of the deprecation message prefix. r>zIt's shiny and newN)rrErArrrFrrs rtest_messageMismatchz6GetDeprecatedModuleAttributeTests.test_messageMismatchsO   ! !  - -   LL   T//12rcr|j|j|jtd|jy)z L{getDeprecatedModuleAttribute} fails the test when used to get an attribute that isn't actually deprecated. somethingNewN)rrErArrrs rtest_notDeprecatedz4GetDeprecatedModuleAttributeTests.test_notDeprecateds1   ! !  - -   LL  rN) rr r!r+rrrBrDrFrIr$rrr;r;[s-eQ1%G 33 3  rr;cy)zj A deprecated module attribute. Used by L{GetDeprecatedModuleAttributeTests.test_deprecated}. Nr$r$rrr>r>rzIt's old and clunkyr>cy)zy A module attribute that is not deprecated. Used by L{GetDeprecatedModuleAttributeTests.test_notDeprecated}. Nr$r$rrrHrHrKr),r+rr9r5 incrementalrrtwisted.internet.deferrrrtwisted.python.deprecaterr twisted.python.failurer twisted.python.reflectr r r twisted.python.utilr twisted.trialrr&rr/rTrVrxrr-rrrrrrr2r;r>r@rrHr$rrrTs 1::J* -",<,  3;v3;lJ0x33J0ZJ.h22J.ZI !=!=I Xm4H88m4`^8h::^8BS8x'C'CS8l*B(66*BZ`F(66`FF  ' '( )   ' '[ABD (D(DD N %--  r