
    tfM                        d Z ddlZddlZddlZddlZddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ ddlmZmZmZmZ ddlmZmZmZ dd	lmZ dd
lmZ  G d d          Z G d d          Z G d deej                  Z G d deej                  Z  G d de          Z! G d de!ej                  Z" G d de!ej                  Z# G d de          Z$ G d de$ej                  Z% G d de$ej                  Z& G d d e          Z' G d! d"e'ej                  Z( G d# d$e'ej                  Z) G d% d&e          Z* G d' d(e*ej                  Z+ G d) d*e*ej                  Z, G d+ d,e          Z- G d- d.e-ej                  Z. G d/ d0e-ej                  Z/ G d1 d2ej                  Z0 G d3 d4          Z1 G d5 d6e1ej                  Z2 G d7 d8e1ej                  Z3 G d9 d:eej                  Z4 G d; d<          Z5 G d= d>e5ej                  Z6 G d? d@e5ej                  Z7 G dA dBej                  Z8 G dC dD          Z9 G dE dFe9ej                  Z: G dG dHe9ej                  Z; G dI dJ          Z< G dK dLe<ej                  Z= G dM dNe<ej                  Z> G dO dP          Z? G dQ dRe?ej                  Z@ G dS dTe?ej                  ZA G dU dV          ZB G dW dXeBej                  ZC G dY dZeBej                  ZD G d[ d\          ZE G d] d^eEej                  ZF G d_ d`eEej                  ZG G da dbej                  ZHdS )ca  
Tests for the behaviour of unit tests.

Many tests in this module follow a simple pattern.  A mixin is defined which
includes test methods for a certain feature.  The mixin is inherited from twice,
once by a class also inheriting from SynchronousTestCase and once from a class
inheriting from TestCase.  These two subclasses are named like
I{SynchronousFooTests} and I{AsynchronousFooTests}, where I{Foo} is related to
the name of the mixin.  Sometimes the mixin is defined in another module, along
with the synchronous subclass.  The mixin is imported into this module to define
the asynchronous subclass.

This pattern allows the same tests to be applied to the two base test case
classes trial provides, ensuring their behavior is the same.

Most new tests should be added in this pattern.  Tests for functionality which
is intentionally only provided by TestCase, not SynchronousTestCase, is excepted
of course.
    N)StringIO)deferreactor)_PYPY)namedAny)reporterrunnerunittestutil)_clearSuite _ForceGarbageCollectionDecorator_iterateTests)	erroneous)SuppressionMixinc                   $    e Zd ZdZd Zd Zd ZdS )ResultsTestMixinzG
    Provide useful APIs for test cases that are about test cases.
    c                     t          j                    | _        | j                            |          | _        t          j                    | _        dS )zt
        Load tests from the given test case class and create a new reporter to
        use for running it.
        N)pyunit
TestLoaderloaderloadTestsFromTestCasesuiter   
TestResultselfr   s     \/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/trial/test/test_tests.py	loadSuitezResultsTestMixin.loadSuite1   s?    
 '))[66u==
 +--    c                    |                      | j                                                   |                     | j        j        g            |                     | j        j        g            |                     | j        j        g            dS )z 
        test the setup
        N)
assertTruer   wasSuccessfulassertEqualerrorsfailuresskipsr   s    r   
test_setUpzResultsTestMixin.test_setUp:   s{     	3355666-r222/444,b11111r   c                     |                      | j                                        |           |                     | j                   |                      | j        j        |           dS )z:
        Asserts that the test count is plausible
        N)r"   r   countTestCasesr   testsRun)r   numTestss     r   assertCountzResultsTestMixin.assertCountC   s]     	2244h???

4=!!!/:::::r   N)__name__
__module____qualname____doc__r   r'   r,    r   r   r   r   ,   sK         . . .2 2 2; ; ; ; ;r   r   c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	SuccessMixinz\
    Tests for the reporting of successful tests in L{twisted.trial.unittest.TestCase}.
    c                 6    t          j                    | _        dS %
        Setup our test case
        N)r   r   resultr&   s    r   setUpzSuccessMixin.setUpQ   s     )++r   c                     dS )z9
        A successful test, used by other tests.
        Nr1   r&   s    r   test_successfulzSuccessMixin.test_successfulW   s      r   c                 J   |                      |j        d           |                      |j        g            |                      |j        g            |                      |j        g            |                      |j        g            |                      |j        g            dS )zd
        Utility function -- assert there is one success and the state is
        plausible
           N)r"   	successesr$   r#   expectedFailuresunexpectedSuccessesr%   r   testr7   s      r   assertSuccessfulzSuccessMixin.assertSuccessful\   s    
 	)1---"---+++0"5553R888r*****r   c                     |                      d          }|                    | j                   |                     || j                   dS )z
        Test that when a successful test is run, it is reported as a success,
        and not as any other kind of result.
        r:   N	__class__runr7   rB   r   rA   s     r   test_successfulIsReportedz&SuccessMixin.test_successfulIsReportedh   sH    
 ~~/00dDK00000r   c                     |                                  }|                    | j                   |                     || j                   dS )zz
        The test case type can be instantiated with no arguments, run, and
        reported as being successful.
        NrD   rG   s     r   test_defaultIsSuccessfulz%SuccessMixin.test_defaultIsSuccessfulq   sE    
 ~~dDK00000r   c                 &   |                      d          }t          j        |          }|                    | j                   |                     || j                   ~t          j                     |                      |            d           dS )zF
        Test that no reference is kept on a successful test.
        r:   N)	rE   weakrefrefrF   r7   rB   gccollectassertIdentical)r   rA   rM   s      r   test_noReferencezSuccessMixin.test_noReferencez   s     ~~/00k$dDK000

SSUUD)))))r   N)
r-   r.   r/   r0   r8   r:   rB   rH   rJ   rQ   r1   r   r   r3   r3   L   sx         , , ,  

+ 
+ 
+1 1 11 1 1
* 
* 
* 
* 
*r   r3   c                       e Zd ZdZdS )SynchronousSuccessTestsN
    Tests for the reporting of successful tests in the synchronous case.
    Nr-   r.   r/   r0   r1   r   r   rS   rS                 r   rS   c                       e Zd ZdZdS )AsynchronousSuccessTestsrT   NrU   r1   r   r   rX   rX      rV   r   rX   c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	SkipMethodsMixinzZ
    Tests for the reporting of skipping tests in L{twisted.trial.unittest.TestCase}.
    c                 :    |                      | j                   dS r5   )r   Skippingr&   s    r   r8   zSkipMethodsMixin.setUp   s     	t}%%%%%r   c                 0    |                      d           dS )z4
        Assert that there are three tests.
           Nr,   r&   s    r   test_countingzSkipMethodsMixin.test_counting        	r   c                    |                      | j                   |                     | j                                                   |                     | j        j        g            |                     | j        j        g            |                     t          | j        j                  d           |                     | j        j	        d           dS )z
        Running a suite in which all methods are individually set to skip
        produces a successful result with no recorded errors or failures, all
        the skipped methods recorded as skips, and no methods recorded as
        successes.
        r^   r   N
r   r   r    r!   r"   r#   r$   lenr%   r=   r&   s    r   test_resultszSkipMethodsMixin.test_results        	

4=!!!3355666-r222/444T]01115550!44444r   c                    |                      | j                   |                     | j                   |                     | j                                                   |                     | j        j        g            |                     | j        j        g            |                     t          | j        j
                  d           |                     | j        j        d           dS )a	  
        Running a suite in which all methods are skipped by C{setUp} raising
        L{SkipTest} produces a successful result with no recorded errors or
        failures, all skipped methods recorded as skips, and no methods recorded
        as successes.
           r   N)r   SkippingSetUpr   r   r    r!   r"   r#   r$   rd   r%   r=   r&   s    r   r'   zSkipMethodsMixin.test_setUp   s     	t)***

4=!!!3355666-r222/444T]01115550!44444r   c                     |                      | j                   d}| j        j        D ]O\  }}|                     |                                t          |          d         t          |                     PdS )z(
        Test that reasons work
        test_N)r   r   r%   r"   shortDescriptionrd   str)r   prefixrA   reasons       r   test_reasonszSkipMethodsMixin.test_reasons   s}     	

4=!!! M/ 	R 	RLD&T2244S[[]]CS[[QQQQ	R 	Rr   c                    |                      | j                   |                     | j                   |                     | j        j        g          }|                     dt          |                     |                     t          |d         d                    |                     d|d         d                    dS )zo
        If a test method raises L{SkipTest} with no reason, a deprecation
        warning is emitted.
        r<   r   categoryzSDo not raise unittest.SkipTest with no arguments! Give a reason for skipping tests!messageN)	r   DeprecatedReasonlessSkipr   r   flushWarningstest_1r"   rd   DeprecationWarning)r   warningss     r    test_deprecatedSkipWithoutReasonz1SkipMethodsMixin.test_deprecatedSkipWithoutReason   s    
 	t4555

4=!!!%%t'D'K&LMMCMM***+Xa[-DEEE"QK	"	
 	
 	
 	
 	
r   N)
r-   r.   r/   r0   r8   r`   re   r'   rp   ry   r1   r   r   rZ   rZ      s{         & & &  5 5 55 5 5R R R
 
 
 
 
r   rZ   c                   T    e Zd ZdZ ed          Z ed          Z ed          ZdS )SynchronousSkipMethodTestsz
    Tests for the reporting of skipping tests in the synchronous case.

    See: L{twisted.trial.test.test_tests.SkipMethodsMixin}
    z/twisted.trial.test.skipping.SynchronousSkippingz4twisted.trial.test.skipping.SynchronousSkippingSetUpz?twisted.trial.test.skipping.SynchronousDeprecatedReasonlessSkipNr-   r.   r/   r0   r   r\   ri   rt   r1   r   r   r{   r{      sQ          xIJJHHSTTM'xI   r   r{   c                   T    e Zd ZdZ ed          Z ed          Z ed          ZdS )AsynchronousSkipMethodTestsz
    Tests for the reporting of skipping tests in the asynchronous case.

    See: L{twisted.trial.test.test_tests.SkipMethodsMixin}
    z0twisted.trial.test.skipping.AsynchronousSkippingz5twisted.trial.test.skipping.AsynchronousSkippingSetUpz@twisted.trial.test.skipping.AsynchronousDeprecatedReasonlessSkipNr|   r1   r   r   r~   r~      sQ          xJKKHHTUUM'xJ   r   r~   c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )SkipClassesMixinzQ
    Test the class skipping features of L{twisted.trial.unittest.TestCase}.
    c                 R    |                      | j                   d| j        _        dS )r6   FN)r   SkippedClass	_setUpRanr&   s    r   r8   zSkipClassesMixin.setUp   s*     	t()))&+###r   c                 0    |                      d           dS )zP
        Skipped test methods still contribute to the total test count.
           Nr_   r&   s    r   r`   zSkipClassesMixin.test_counting  ra   r   c                 x    |                      | j                   |                     | j        j                   dS )zP
        The C{setUp} method is not called if the class is set to skip.
        N)r   r   assertFalser   r   r&   s    r   test_setUpRanzSkipClassesMixin.test_setUpRan
  s8     	

4=!!!*455555r   c                    |                      | j                   |                     | j                                                   |                     | j        j        g            |                     | j        j        g            |                     t          | j        j                  d           |                     | j        j	        d           dS )a  
        Skipped test methods don't cause C{wasSuccessful} to return C{False},
        nor do they contribute to the C{errors} or C{failures} of the reporter,
        or to the count of successes.  They do, however, add elements to the
        reporter's C{skips} list.
        r   r   Nrc   r&   s    r   re   zSkipClassesMixin.test_results  rf   r   c                     |                      | j                   g d}d | j        j        D             }|                     ||           dS )z
        Test methods which raise L{unittest.SkipTest} or have their C{skip}
        attribute set to something are skipped.
        )classskip2r   r   c                     g | ]\  }}|S r1   r1   ).0rA   ro   s      r   
<listcomp>z1SkipClassesMixin.test_reasons.<locals>.<listcomp>'  s    GGG<4GGGr   N)r   r   r%   r"   r   expectedReasonsreasonsGivens      r   rp   zSkipClassesMixin.test_reasons  sW    
 	

4=!!!>>>GG4=3FGGG,77777r   N)	r-   r.   r/   r0   r8   r`   r   re   rp   r1   r   r   r   r      si         , , ,  6 6 65 5 5	8 	8 	8 	8 	8r   r   c                   (    e Zd ZdZ ed          ZdS )SynchronousSkipClassTestsz
    Test the class skipping features in the synchronous case.

    See: L{twisted.trial.test.test_tests.SkipClassesMixin}
    z3twisted.trial.test.skipping.SynchronousSkippedClassNr-   r.   r/   r0   r   r   r1   r   r   r   r   +  s*          8QRRLLLr   r   c                   (    e Zd ZdZ ed          ZdS )AsynchronousSkipClassTestsz
    Test the class skipping features in the asynchronous case.

    See: L{twisted.trial.test.test_tests.SkipClassesMixin}
    z4twisted.trial.test.skipping.AsynchronousSkippedClassNr   r1   r   r   r   r   5  s*          8RSSLLLr   r   c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
	TodoMixinzv
    Tests for the individual test method I{expected failure} features of
    L{twisted.trial.unittest.TestCase}.
    c                 :    |                      | j                   dS r5   )r   Todor&   s    r   r8   zTodoMixin.setUpE  s     	ty!!!!!r   c                 0    |                      d           dS )z9
        Ensure that we've got three test cases.
        r^   Nr_   r&   s    r   r`   zTodoMixin.test_countingK  ra   r   c                 F   |                      | j                   |                     | j                                                   |                     | j        j        g            |                     | j        j        g            |                     | j        j        g            |                     t          | j        j	                  d           |                     t          | j        j
                  d           |                     | j        j        d           dS )a  
        Running a suite in which all methods are individually marked as expected
        to fail produces a successful result with no recorded errors, failures,
        or skips, all methods which fail and were expected to fail recorded as
        C{expectedFailures}, and all methods which pass but which were expected
        to fail recorded as C{unexpectedSuccesses}.  Additionally, no tests are
        recorded as successes.
        rh   r<   r   Nr   r   r    r!   r"   r#   r$   r%   rd   r>   r?   r=   r&   s    r   re   zTodoMixin.test_resultsQ       	

4=!!!3355666-r222/444,b111T];<<a@@@T]>??CCC0!44444r   c                     |                      | j                   ddg}d | j        j        D             }|                     ||           dS )E
        Ensure that expected failures are handled properly.
        todo1todo2c                 $    g | ]\  }}}|j         S r1   ro   r   ters       r   r   z3TodoMixin.test_expectedFailures.<locals>.<listcomp>i       OOOWQ1OOOr   Nr   r   r>   r"   r   s      r   test_expectedFailureszTodoMixin.test_expectedFailuresc  sV     	

4=!!!"G,OO0NOOO,77777r   c                     |                      | j                   dg}d | j        j        D             }|                     ||           dS )>
        Ensure that unexpected successes are caught.
        todo3c                 "    g | ]\  }}|j         S r1   r   r   r   r   s      r   r   z6TodoMixin.test_unexpectedSuccesses.<locals>.<listcomp>r      OOOTQOOOr   Nr   r   r?   r"   r   s      r   test_unexpectedSuccessesz"TodoMixin.test_unexpectedSuccessesl  sS     	

4=!!!")OOT]-NOOO,77777r   c                    |                      | j                   |                     | j                   |                     | j                                                   |                     t          | j        j                  d           |                     | j        j	        g            |                     | j        j
        g            |                     t          | j        j                  d           |                     t          | j        j                  d           |                     | j        j        d           dS )z|
        C{setUp} is excluded from the failure expectation defined by a C{todo}
        attribute on a test method.
        r<   r   N)r   	SetUpTodor   r   r   r!   r"   rd   r#   r$   r%   r>   r?   r=   r&   s    r   test_expectedSetUpFailurez#TodoMixin.test_expectedSetUpFailureu  s   
 	t~&&&

4=!!!4466777T]122A666/444,b111T];<<a@@@T]>??CCC0!44444r   c                    |                      | j                   |                     | j                   |                     | j                                                   |                     t          | j        j                  d           |                     | j        j	        g            |                     | j        j
        g            |                     t          | j        j                  d           |                     t          | j        j                  d           |                     | j        j        d           dS )z
        C{tearDown} is excluded from the failure expectation defined by a C{todo}
        attribute on a test method.
        r<   r   N)r   TearDownTodor   r   r   r!   r"   rd   r#   r$   r%   r>   r?   r=   r&   s    r   test_expectedTearDownFailurez&TodoMixin.test_expectedTearDownFailure  s   
 	t()))

4=!!!4466777T]122A666/444,b111T];<<a@@@ 	T]>??CCC0!44444r   N)r-   r.   r/   r0   r8   r`   re   r   r   r   r   r1   r   r   r   r   ?  s         
" " "  5 5 5$8 8 88 8 85 5 55 5 5 5 5r   r   c                   T    e Zd ZdZ ed          Z ed          Z ed          ZdS )SynchronousTodoTestszx
    Test the class skipping features in the synchronous case.

    See: L{twisted.trial.test.test_tests.TodoMixin}
    z+twisted.trial.test.skipping.SynchronousTodoz0twisted.trial.test.skipping.SynchronousSetUpTodoz3twisted.trial.test.skipping.SynchronousTearDownTodoNr-   r.   r/   r0   r   r   r   r   r1   r   r   r   r     sJ          8ABBDKLLI8QRRLLLr   r   c                   T    e Zd ZdZ ed          Z ed          Z ed          ZdS )AsynchronousTodoTestszy
    Test the class skipping features in the asynchronous case.

    See: L{twisted.trial.test.test_tests.TodoMixin}
    z,twisted.trial.test.skipping.AsynchronousTodoz1twisted.trial.test.skipping.AsynchronousSetUpTodoz4twisted.trial.test.skipping.AsynchronousTearDownTodoNr   r1   r   r   r   r     sJ          8BCCDLMMI8RSSLLLr   r   c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )ClassTodoMixinzj
    Tests for the class-wide I{expected failure} features of
    L{twisted.trial.unittest.TestCase}.
    c                 :    |                      | j                   dS r5   )r   	TodoClassr&   s    r   r8   zClassTodoMixin.setUp  s     	t~&&&&&r   c                 0    |                      d           dS )z8
        Ensure that we've got four test cases.
        r   Nr_   r&   s    r   r`   zClassTodoMixin.test_counting  ra   r   c                 F   |                      | j                   |                     | j                                                   |                     | j        j        g            |                     | j        j        g            |                     | j        j        g            |                     t          | j        j	                  d           |                     t          | j        j
                  d           |                     | j        j        d           dS )a  
        Running a suite in which an entire class is marked as expected to fail
        produces a successful result with no recorded errors, failures, or
        skips, all methods which fail and were expected to fail recorded as
        C{expectedFailures}, and all methods which pass but which were expected
        to fail recorded as C{unexpectedSuccesses}.  Additionally, no tests are
        recorded as successes.
        rh   r   Nr   r&   s    r   re   zClassTodoMixin.test_results  r   r   c                     |                      | j                   ddg}d | j        j        D             }|                     ||           dS )r   methodr   c                 $    g | ]\  }}}|j         S r1   r   r   s       r   r   z8ClassTodoMixin.test_expectedFailures.<locals>.<listcomp>  r   r   Nr   r   s      r   r   z$ClassTodoMixin.test_expectedFailures  sV     	

4=!!!#W-OO0NOOO,77777r   c                     |                      | j                   ddg}d | j        j        D             }|                     ||           dS )r   r   r   c                 "    g | ]\  }}|j         S r1   r   r   s      r   r   z;ClassTodoMixin.test_unexpectedSuccesses.<locals>.<listcomp>  r   r   Nr   r   s      r   r   z'ClassTodoMixin.test_unexpectedSuccesses  sV     	

4=!!!#W-OOT]-NOOO,77777r   N	r-   r.   r/   r0   r8   r`   re   r   r   r1   r   r   r   r     si         
' ' '  5 5 5$8 8 88 8 8 8 8r   r   c                   (    e Zd ZdZ ed          ZdS )SynchronousClassTodoTestsz
    Tests for the class-wide I{expected failure} features in the synchronous case.

    See: L{twisted.trial.test.test_tests.ClassTodoMixin}
    z0twisted.trial.test.skipping.SynchronousTodoClassNr-   r.   r/   r0   r   r   r1   r   r   r   r     s*          KLLIIIr   r   c                   (    e Zd ZdZ ed          ZdS )AsynchronousClassTodoTestsz
    Tests for the class-wide I{expected failure} features in the asynchronous case.

    See: L{twisted.trial.test.test_tests.ClassTodoMixin}
    z1twisted.trial.test.skipping.AsynchronousTodoClassNr   r1   r   r   r   r     s*          LMMIIIr   r   c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )StrictTodoMixinz
    Tests for the I{expected failure} features of
    L{twisted.trial.unittest.TestCase} in which the exact failure which is
    expected is indicated.
    c                 :    |                      | j                   dS r5   )r   
StrictTodor&   s    r   r8   zStrictTodoMixin.setUp  s     	t'''''r   c                 0    |                      d           dS )z3
        Assert there are seven test cases
           Nr_   r&   s    r   r`   zStrictTodoMixin.test_counting  ra   r   c                 z   |                      | j                   |                     | j                                                   |                     t          | j        j                  d           |                     t          | j        j                  d           |                     t          | j        j                  d           |                     t          | j        j	                  d           |                     | j        j
        d           |                     | j        j        g            dS )z
        A test method which is marked as expected to fail with a particular
        exception is only counted as an expected failure if it does fail with
        that exception, not if it fails with some other exception.
        rh   r<   r^   r   N)r   r   r   r!   r"   rd   r#   r$   r>   r?   r=   r%   r&   s    r   re   zStrictTodoMixin.test_results  s    	

4=!!!4466777T]122A666T]344a888T];<<a@@@T]>??CCC0!444,b11111r   c                     |                      | j                   g d}d | j        j        D             }|                     ||           dS )r   )r   r   todo5c                 $    g | ]\  }}}|j         S r1   r   r   s       r   r   z9StrictTodoMixin.test_expectedFailures.<locals>.<listcomp>"  s     PPPgaAPPPr   Nr   r   r   reasonsGottens      r   r   z%StrictTodoMixin.test_expectedFailures  sW     	

4=!!!555PP1OPPP-88888r   c                     |                      | j                   t          gdfg}d | j        j        D             }|                     ||           dS )r   todo7c                 0    g | ]\  }}|j         |j        fS r1   )r#   ro   r   s      r   r   z<StrictTodoMixin.test_unexpectedSuccesses.<locals>.<listcomp>+  s2     
 
 
%)QQXqx 
 
 
r   N)r   r   RuntimeErrorr?   r"   r   s      r   r   z(StrictTodoMixin.test_unexpectedSuccesses%  sh     	

4=!!!)NG45
 
-1]-N
 
 
 	-88888r   Nr   r1   r   r   r   r     si         ( ( (  2 2 29 9 9	9 	9 	9 	9 	9r   r   c                   (    e Zd ZdZ ed          ZdS )SynchronousStrictTodoTestsz
    Tests for the expected failure case when the exact failure that is expected
    is indicated in the synchronous case

    See: L{twisted.trial.test.test_tests.StrictTodoMixin}
    z1twisted.trial.test.skipping.SynchronousStrictTodoNr-   r.   r/   r0   r   r   r1   r   r   r   r   1  s*          MNNJJJr   r   c                   (    e Zd ZdZ ed          ZdS )AsynchronousStrictTodoTestsz
    Tests for the expected failure case when the exact failure that is expected
    is indicated in the asynchronous case

    See: L{twisted.trial.test.test_tests.StrictTodoMixin}
    z2twisted.trial.test.skipping.AsynchronousStrictTodoNr   r1   r   r   r   r   <  s*          NOOJJJr   r   c                   $    e Zd ZdZd Zd Zd ZdS )ReactorCleanupTestszc
    Tests for cleanup and reporting of reactor event sources left behind by test
    methods.
    c                     t          j        t                                | _        t	          j                    | _        dS r5   )r   Reporterr   r7   r	   r   r   r&   s    r   r8   zReactorCleanupTests.setUpM  s.     '

33'))r   c                    | j                             d          }|                    | j                   |                     | j                                                   |                     | j        j        d           | j        j        d         d         }| 	                    |
                    t          j                             dS )zm
        Trial reports a L{util.DirtyReactorAggregateError} if a test leaves
        sockets behind.
        z@twisted.trial.test.erroneous.SocketOpenTest.test_socketsLeftOpenr<   r   N)r   
loadByNamerF   r7   r   r!   r"   r=   r#   r    checkr   DirtyReactorAggregateErrorr   r   failures      r   test_leftoverSocketsz(ReactorCleanupTests.test_leftoverSocketsT  s    
 &&N
 
 			$+2244555 	.222+$Q'*d&EFFGGGGGr   c                    t          j        d          }|                    | j                   |                     | j                                                   | j        j        d         d         }|                     | j        j        d           | 	                    |
                    t          j                             dS )z
        Trial reports a L{util.DirtyReactorAggregateError} and fails the test
        if a test leaves a L{DelayedCall} hanging.
        test_leftoverPendingCallsr   r<   N)r   r   rF   r7   r   r!   r#   r"   r=   r    r   r   r   r   s      r   r   z-ReactorCleanupTests.test_leftoverPendingCallse  s    
 -.IJJ		$+2244555+$Q'*.222d&EFFGGGGGr   N)r-   r.   r/   r0   r8   r   r   r1   r   r   r   r   G  sS         
* * *H H H"
H 
H 
H 
H 
Hr   r   c                   *    e Zd ZdZd Zd Zd Zd ZdS )FixtureMixinzB
    Tests for fixture helper methods (e.g. setUp, tearDown).
    c                 f    t          j                    | _         t          j                    | _        dS r5   )r   r   r   r   r   r&   s    r   r8   zFixtureMixin.setUpw  s(     !)++'))r   c                    | j                             | j                  }|                    | j                   |                     t          | j        j                  dk               |                     | j        j        d         d         j	        t          j                   |                     d| j        j                   dS )zO
        When setUp fails, the error is recorded in the result object.
        r   r<   N)r   r   TestFailureInSetUprF   r   r    rd   r#   assertIsInstancevaluer   FoolishErrorr"   r=   r   s     r   test_brokenSetUpzFixtureMixin.test_brokenSetUp~  s     11$2IJJ		$-   DM011A5666dm215a8>	@VWWWDM344444r   c                 ~   | j                             | j                  }|                    | j                   | j        j        }|                     t          |          dk               |                     |d         d         j	        t          j                   |                     d| j        j                   dS )zR
        When tearDown fails, the error is recorded in the result object.
        r   r<   N)r   r   TestFailureInTearDownrF   r   r#   r    rd   r   r   r   r   r"   r=   )r   r   r#   s      r   test_brokenTearDownz FixtureMixin.test_brokenTearDown  s     11$2LMM		$-   %Fa(((fQil0)2HIIIDM344444r   c                    | j                             | j                  }t          |          d         }|                     |j                   |                    | j                   | j        j        }| 	                    t          |          dk               |                     |d         d         j        t          j                   |                     d| j        j                   | 	                    |j                   dS )zP
        L{SynchronousTestCase.tearDown} runs when a test method fails.
        r   r<   N)r   r   TestFailureButTearDownRunslistr   tornDownrF   r   r#   r    rd   r   r   r   r   r"   r=   )r   r   caser#   s       r   test_tearDownRunsOnTestFailurez+FixtureMixin.test_tearDownRunsOnTestFailure  s     11$2QRRE{{1~'''		$-   %Fa(((fQil0)2HIIIDM3444&&&&&r   N)r-   r.   r/   r0   r8   r   r   r  r1   r   r   r   r   r  sZ         * * *5 5 5	5 	5 	5' ' ' ' 'r   r   c                   T    e Zd ZdZ ed          Z ed          Z ed          ZdS )SynchronousFixtureTestsz
    Tests for broken fixture helper methods in the synchronous case

    See: L{twisted.trial.test.test_tests.FixtureMixin}
    z:twisted.trial.test.erroneous.SynchronousTestFailureInSetUpz=twisted.trial.test.erroneous.SynchronousTestFailureInTearDownzBtwisted.trial.test.erroneous.SynchronousTestFailureButTearDownRunsNr-   r.   r/   r0   r   r   r   r   r1   r   r   r  r    s_          "D  %HG  "*L" "r   r  c                   T    e Zd ZdZ ed          Z ed          Z ed          ZdS )AsynchronousFixtureTestsz
    Tests for broken fixture helper methods in the asynchronous case

    See: L{twisted.trial.test.test_tests.FixtureMixin}
    z;twisted.trial.test.erroneous.AsynchronousTestFailureInSetUpz>twisted.trial.test.erroneous.AsynchronousTestFailureInTearDownzCtwisted.trial.test.erroneous.AsynchronousTestFailureButTearDownRunsNr  r1   r   r   r	  r	    s_          "E  %HH  "*M" "r   r	  c                   j    e Zd ZdZ ed          Z ed          Z ed          Z ed          ZdS )AsynchronousSuppressionTestsz
    Tests for the warning suppression features of
    L{twisted.trial.unittest.TestCase}

    See L{twisted.trial.test.test_suppression.SuppressionMixin}
    z?twisted.trial.test.suppression.AsynchronousTestSetUpSuppressionzBtwisted.trial.test.suppression.AsynchronousTestTearDownSuppressionz:twisted.trial.test.suppression.AsynchronousTestSuppressionz;twisted.trial.test.suppression.AsynchronousTestSuppression2N)	r-   r.   r/   r0   r   TestSetUpSuppressionTestTearDownSuppressionTestSuppressionTestSuppression2r1   r   r   r  r    su          $8I  'hL  hD O  xE r   r  c                   P    e Zd ZdZ G d dej                  Zd Zd Zd Z	d Z
dS )	GCMixinz
    I provide a few mock tests that log setUp, tearDown, test execution and
    garbage collection. I'm used to test whether gc.collect gets called.
    c                   $    e Zd ZdZd Zd Zd ZdS )GCMixin.BasicTestz#
        Mock test to run.
        c                 0    |                      d           dS )z$
            Mock setUp
            r8   N_logr&   s    r   r8   zGCMixin.BasicTest.setUp  s     IIgr   c                 0    |                      d           dS )z(
            Mock test case
            rA   Nr  r&   s    r   test_foozGCMixin.BasicTest.test_foo  s     IIfr   c                 0    |                      d           dS )z,
            Mock tear tearDown
            tearDownNr  r&   s    r   r  zGCMixin.BasicTest.tearDown  s     IIj!!!!!r   N)r-   r.   r/   r0   r8   r  r  r1   r   r   	BasicTestr    sK        	 		 	 		 	 		" 	" 	" 	" 	"r   r  c                 :    | j                             |           dS )z
        Log function
        N)_collectCalledappend)r   msgs     r   r  zGCMixin._log  s!     	""3'''''r   c                 0    |                      d           dS )zFake gc.collectrO   Nr  r&   s    r   rO   zGCMixin.collect  s    		)r   c                 z    g | _         | j        | j        _        t          j        | _        | j        t          _        dS r5   )r  r  r  rN   rO   _oldCollectr&   s    r   r8   zGCMixin.setUp  s/     !"i:\


r   c                 (    | j         t          _        dS z$
        Tear down the test
        N)r"  rN   rO   r&   s    r   r  zGCMixin.tearDown  s     %


r   N)r-   r.   r/   r0   r
   SynchronousTestCaser  r  rO   r8   r  r1   r   r   r  r    s         
" " " " "H0 " " ".( ( (  " " "& & & & &r   r  c                       e Zd ZdZd ZdS )GarbageCollectionDefaultTestsz@
    By default, tests should not force garbage collection.
    c                     |                      d          }t          j                    }|                    |           |                     | j        g d           dS )zH
        By default, tests should not force garbage collection.
        r  )r8   rA   r  N)r  r   r   rF   r"   r  r@   s      r   test_collectNotDefaultz4GarbageCollectionDefaultTests.test_collectNotDefault  s[     ~~j))$&&,.K.K.KLLLLLr   N)r-   r.   r/   r0   r)  r1   r   r   r'  r'    s2         M M M M Mr   r'  c                       e Zd ZdZd ZdS )GarbageCollectionTestsz-
    Test that, when force GC, it works.
    c                     t                               d          }t          |          }t          j                    }|                    |           |                     | j        g d           dS )zG
        test gc.collect is called before and after each test.
        r  )rO   r8   rA   r  rO   N)r+  r  r   r   r   rF   r"   r  r@   s      r   test_collectCalledz)GarbageCollectionTests.test_collectCalled*  su     &//
;;/55$&&!T!T!T	
 	
 	
 	
 	
r   N)r-   r.   r/   r0   r-  r1   r   r   r+  r+  %  s-         

 

 

 

 

r   r+  c                   X    e Zd ZdZd Zd Z ej        ed          d             Z	d Z
dS )UnhandledDeferredTestsz\
    Test what happens when we have an unhandled deferred left around after
    a test.
    c                     ddl m} t          j                     t	          |                    d                    | _        dS )r6   r   )weirdtest_unhandledDeferredN)twisted.trial.testr1  rN   disabler   TestBleedingtest1)r   r1  s     r   r8   zUnhandledDeferredTests.setUp=  sJ     	-,,,,, 	
5788
 



r   c                     t          j                    }|                     |           |                     t	          |j                  dd           dS )zo
        Forcing garbage collection should cause unhandled Deferreds to be
        reported as errors.
        r<   z(Unhandled deferred passed without noticeN)r   r   r6  r"   rd   r#   )r   r7   s     r   test_isReportedz&UnhandledDeferredTests.test_isReportedI  sX    
 $&&

6#M	
 	
 	
 	
 	
r   zGC works differently on PyPy.c                 N   t          j                    }|                     |           |                                  t	          t
          j                  }|                     |dd           |                                 }|                     t	          |          dd           dS )z
        Forcing garbage collection in the test should mean that there are
        no unreachable cycles immediately after the test completes.
        r   zunreachable cycle still existedzErrors logged after gc.collectN)r   r   r6  flushLoggedErrorsrd   rN   garbager"   )r   r7   nxs       r   test_doesntBleedz'UnhandledDeferredTests.test_doesntBleedT  s     $&&

6    
OOA@AAA""$$Q$DEEEEEr   c                 z    t          j                     t          j                     |                                  dS r$  )rN   rO   enabler:  r&   s    r   r  zUnhandledDeferredTests.tearDowne  s2     	

	     r   N)r-   r.   r/   r0   r8   r8  r   skipIfr   r>  r  r1   r   r   r/  r/  7  sy         


 

 

	
 	
 	
 V]59::F F ;:F ! ! ! ! !r   r/  c                   L     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Z xZS )
AddCleanupMixinz1
    Test the addCleanup method of TestCase.
    c                     t                                                       t          j                    | _        |                                 | _        dS r5   )superr8   r   r   r7   
AddCleanuprA   )r   rE   s    r   r8   zAddCleanupMixin.setUps  s;     	)++OO%%			r   c                     | j         j        | j         _        | j                             | j         j        d           | j                             | j                   |                     ddg| j         j                   dS )zQ
        Callables added with C{addCleanup} are run even if setUp fails.
        foor8   N)	rA   brokenSetUpr8   
addCleanupr  rF   r7   r"   logr&   s    r   !test_addCleanupCalledIfSetUpFailsz1AddCleanupMixin.test_addCleanupCalledIfSetUpFails{  sj     )/		TY-u555	dk"""'5)49=99999r   c                     | j         j        | j         _        | j                             | j         j        d           | j                             | j                   |                     ddg| j         j                   dS )z
        Callables added with C{addCleanup} are run even if setUp raises
        L{SkipTest}. This allows test authors to reliably provide clean up
        code using C{addCleanup}.
        rH  r8   N)	rA   skippingSetUpr8   rJ  r  rF   r7   r"   rK  r&   s    r   !test_addCleanupCalledIfSetUpSkipsz1AddCleanupMixin.test_addCleanupCalledIfSetUpSkips  sj     )1		TY-u555	dk"""'5)49=99999r   c                    | j                             | j         j        d           | j                             | j         j        d           | j                             | j                   |                     g d| j         j                   dS )z~
        Callables added with C{addCleanup} should be called before C{tearDown}
        in reverse order of addition.
        rH  barr8   runTestrQ  rH  r  NrA   rJ  r  rF   r7   r"   rK  r&   s    r   #test_addCleanupCalledInReverseOrderz3AddCleanupMixin.test_addCleanupCalledInReverseOrder  s{    
 		TY-u555	TY-u555	dk"""GGGWWWWWr   c                    | j                             | j         j        d           | j                             | j                   |                     | j                                                   |                     dt          | j        j	                             | j        j	        \  \  }}|                     || j                    |                     |
                                d           dS )z
        Errors raised in cleanup functions should be treated like errors in
        C{tearDown}. They should be added as errors and fail the test. Skips,
        todos and failures are all treated as errors.
        rH  r<   N)rA   rJ  failrF   r7   r   r!   r"   rd   r#   getErrorMessager   rA   errors      r   test_errorInCleanupIsCapturedz-AddCleanupMixin.test_errorInCleanupIsCaptured  s     		TY^U333	dk"""2244555C 233444+,$ty)))..00%88888r   c                    | j                             | j         j        d           | j                             | j         j        d           | j                             | j                   |                     g d| j         j                   |                     dt          | j        j	                             | j        j	        \  \  }}|                     || j                    |                     |
                                d           dS )zq
        If a cleanup raises an error then that does not stop the other
        cleanups from being run.
        rH  rQ  )r8   rS  rH  r  r<   N)rA   rJ  r  rW  rF   r7   r"   rK  rd   r#   rX  rY  s      r   &test_cleanupsContinueRunningAfterErrorz6AddCleanupMixin.test_cleanupsContinueRunningAfterError  s    
 		TY-u555	TY^U333	dk"""@@@$)-PPPC 233444+,$ty)))..00%88888r   c                    | j                             | j         j        d           | j                             | j         j        d           | j                             | j                   |                     g d| j         j                   |                     dt          | j        j                             | j        j        \  \  }}\  }}|                     || j                    |                     || j                    |                     |	                                d           |                     |	                                d           dS )zm
        If more than one cleanup fails, then the test should fail with more
        than one error.
        rH  rQ  )r8   rS  r  rh   N)
rA   rJ  rW  rF   r7   r"   rK  rd   r#   rX  )r   r6  error1test2error2s        r   test_multipleErrorsReportedz+AddCleanupMixin.test_multipleErrorsReported  s'   
 		TY^U333	TY^U333	dk"""99949=IIIC 233444-1[-?*%/5&	***	***//115999//11599999r   c                     g | j                             fd           d| j                             | j                   d| j                             | j                   |                     dg           dS )zA
        A function registered as a cleanup is run once.
        c                  .                                    S )N)r  )cleanupsstages   r   <lambda>z6AddCleanupMixin.test_cleanupRunsOnce.<locals>.<lambda>  s    X__U%;%; r   firstsecondN)rA   rJ  rF   r7   r"   )r   re  rf  s    @@r   test_cleanupRunsOncez$AddCleanupMixin.test_cleanupRunsOnce  s     	;;;;;<<<	dk""" 	dk"""G9-----r   )r-   r.   r/   r0   r8   rL  rO  rU  r[  r]  rb  rj  __classcell__)rE   s   @r   rC  rC  n  s         & & & & &: : :	: 	: 	:X X X9 9 99 9 9: : : . . . . . . .r   rC  c                   (    e Zd ZdZ ed          ZdS )SynchronousAddCleanupTestsz
    Test the addCleanup method of TestCase in the synchronous case

    See: L{twisted.trial.test.test_tests.AddCleanupMixin}
    z1twisted.trial.test.skipping.SynchronousAddCleanupN)r-   r.   r/   r0   r   rF  r1   r   r   rm  rm    s*          MNNJJJr   rm  c                   .    e Zd ZdZ ed          Zd ZdS )AsynchronousAddCleanupTestsz
    Test the addCleanup method of TestCase in the asynchronous case

    See: L{twisted.trial.test.test_tests.AddCleanupMixin}
    z2twisted.trial.test.skipping.AsynchronousAddCleanupc                      fd} j                              j         j        d            j                             |d            j                              j                                        g d j         j                   dS )z
        If an added callable returns a L{Deferred}, then the test should wait
        until that L{Deferred} has fired before running the next cleanup
        method.
        c                     t          j                    }t          j        d|j        |            |                    j        j                  S )Nr   )r   Deferredr   	callLatercallbackaddCallbackrA   r  )rs   dr   s     r   cleanupzMAsynchronousAddCleanupTests.test_addCleanupWaitsForDeferreds.<locals>.cleanup  s>      AaW555==!1222r   rH  rQ  rR  NrT  )r   rw  s   ` r    test_addCleanupWaitsForDeferredsz<AsynchronousAddCleanupTests.test_addCleanupWaitsForDeferreds  s    	3 	3 	3 	3 	3
 		TY-u555	We,,,	dk"""GGGWWWWWr   N)r-   r.   r/   r0   r   rF  rx  r1   r   r   ro  ro    sD          NOOJX X X X Xr   ro  c                       e Zd ZdZd Zd ZdS )SuiteClearingMixinzM
    Tests for our extension that allows us to clear out a L{TestSuite}.
    c                 8   t          j                    }|                    |                                            |                     d|                                           t          |           |                     d|                                           dS )z_
        Calling L{_clearSuite} on a populated L{TestSuite} removes
        all tests.
        r<   r   N)r
   	TestSuiteaddTestTestCaser"   r)   r   r   s     r   test_clearSuitez"SuiteClearingMixin.test_clearSuite  s    
 "$$dmmoo&&&E0022333EE002233333r   c                 8   t          j                    }|                    |                                            |                     d|                                           t          |           |                     d|                                           dS )z
        Calling L{_clearSuite} on a populated standard library
        L{TestSuite} removes all tests.

        This test is important since C{_clearSuite} operates by mutating
        internal variables.
        r<   r   N)r   r|  r}  r~  r"   r)   r   r   s     r   test_clearPyunitSuitez(SuiteClearingMixin.test_clearPyunitSuite  s      ""dmmoo&&&E0022333EE002233333r   N)r-   r.   r/   r0   r  r  r1   r   r   rz  rz    s<         
4 
4 
44 4 4 4 4r   rz  c                        e Zd ZdZej        ZdS )SynchronousSuiteClearingTestsz
    Tests for our extension that allows us to clear out a L{TestSuite} in the
    synchronous case.

    See L{twisted.trial.test.test_tests.SuiteClearingMixin}
    Nr-   r.   r/   r0   r
   r%  r~  r1   r   r   r  r    "          +HHHr   r  c                        e Zd ZdZej        ZdS )AsynchronousSuiteClearingTestsz
    Tests for our extension that allows us to clear out a L{TestSuite} in the
    asynchronous case.

    See L{twisted.trial.test.test_tests.SuiteClearingMixin}
    Nr-   r.   r/   r0   r
   r~  r1   r   r   r  r  &  "           HHHr   r  c                   T    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd ZdS )TestDecoratorMixinz1
    Tests for our test decoration features.
    c                     |                      |j        |j        d           t          |dd          }t          |dd          }|                     ||           ||cxu rn dS |                     ||           dS dS )zB
        Assert that the given decorated tests are equal.
        Different class_originalTestN)r"   rE   getattrrP   )r   observedexpectedobservedOriginalexpectedOriginals        r   assertTestsEqualz#TestDecoratorMixin.assertTestsEqual6  s     	+X-?ARSSS"8_dCC"8_dCC-/?@@@/777777777  844444 87r   c                 z   |                      |j        |j        d           |                      t          |j                  t          |j                  d           t	          |j        |j                  D ]C\  }}t          |dd          |                     ||           -|                     ||           DdS )zS
        Assert that the given test suites with decorated tests are equal.
        r  zDifferent number of tests._testsN)r"   rE   rd   r  zipr  assertSuitesEqualr  )r   r  r  observedTestexpectedTests        r   r  z$TestDecoratorMixin.assertSuitesEqualA  s     	+X-?ARSSS  #ho"6"68T	
 	
 	
 +.hox*O*O 	B 	B&L,|Xt44@&&|\BBBB%%lLAAAA		B 	Br   c                     |                                  }t          j        |          }ddlm}  |            }|                    |           |                     |j        |           dS )z
        For decorated tests, C{run} uses a result adapter that preserves the
        test decoration for calls to C{addError}, C{startTest} and the like.

        See L{reporter._AdaptedReporter}.
        r   LoggingReporterN)r~  r
   TestDecorator twisted.trial.test.test_reporterr  rF   r  rA   r   rA   decoratedTestr  r7   s        r   test_usesAdaptedReporterWithRunz2TestDecoratorMixin.test_usesAdaptedReporterWithRunO  sr     }} .t44DDDDDD ""&!!!fk=99999r   c                     |                                  }t          j        |          }ddlm}  |            } ||           |                     |j        |           dS )z
        For decorated tests, C{__call__} uses a result adapter that preserves
        the test decoration for calls to C{addError}, C{startTest} and the
        like.

        See L{reporter._AdaptedReporter}.
        r   r  N)r~  r
   r  r  r  r  rA   r  s        r    test_usesAdaptedReporterWithCallz3TestDecoratorMixin.test_usesAdaptedReporterWithCall_  sn     }} .t44DDDDDD ""ffk=99999r   c                     |                                  }t          j        |t          j                  }|                     t          j        |          |           dS )z
        Calling L{decorate} on a single test case returns the test case
        decorated with the provided decorator.
        Nr~  r
   decorater  r  )r   rA   r  s      r   test_decorateSingleTestz*TestDecoratorMixin.test_decorateSingleTestp  sM    
 }} )$0FGGh4T::MJJJJJr   c                    |                                  }t          j        |g          }t          j        |t          j                  }|                     |t          j        t          j        |          g                     dS )z
        Calling L{decorate} on a test suite will return a test suite with
        each test decorated with the provided decorator.
        Nr~  r
   r|  r  r  r  r   rA   r   r  s       r   test_decorateTestSuitez)TestDecoratorMixin.test_decorateTestSuitey  sx    
 }}"D6** )%1GHH8-x/Ed/K/K.LMM	
 	
 	
 	
 	
r   c                    |                                  }t          j        |g          }t          j        |t          j                  }|                     |t          j        t          j        |          g                     |                     |t          j        t          j        |          g                     dS )zU
        Calling L{decorate} on a test suite will mutate the original suite.
        Nr  r  s       r   #test_decorateInPlaceMutatesOriginalz6TestDecoratorMixin.test_decorateInPlaceMutatesOriginal  s     }}"D6** )%1GHH8-x/Ed/K/K.LMM	
 	
 	
 	8%x'=d'C'C&DEE	
 	
 	
 	
 	
r   c                 F   t          t          dd          }|t          j        d          |                                 }t          j        |g          } ||          }t          j        |t          j                    ||          }|                     ||           dS )ac  
        When decorating a test suite in-place, the number of references to the
        test objects in that test suite should stay the same.

        Previously, L{unittest.decorate} recreated a test suite, so the
        original suite kept references to the test objects. This test is here
        to ensure the problem doesn't reappear again.
        getrefcountNz*getrefcount not supported on this platform)	r  sysr
   SkipTestr~  r|  r  r  r"   )r   r  rA   r   count1count2s         r    test_decorateTestSuiteReferencesz3TestDecoratorMixin.test_decorateTestSuiteReferences  s     c=$77#$PQQQ}}"D6**T""%!7888T""(((((r   c                 \   |                                  }t          j        t          j        |g          g          }t          j        |t          j                  }t          j        t          j        t          j        |          g          g          }|                     ||           dS )z
        Calling L{decorate} on a test suite with nested suites will return a
        test suite that maintains the same structure, but with all tests
        decorated.
        Nr  )r   rA   r   r  r  s        r   test_decorateNestedTestSuitez/TestDecoratorMixin.test_decorateNestedTestSuite  s     }}"H$6v$>$>#?@@ )%1GHH%!7!=!= >??@
 
 	}h77777r   c                     |                                  }t          j        |t          j                  }t          j        |t          j                  }|                     |t          j        |                     dS )z
        Calling L{decorate} on a test suite with already-decorated tests
        decorates all of the tests in the suite again.
        Nr  )r   rA   r  redecoratedTests       r   test_decorateDecoratedSuitez.TestDecoratorMixin.test_decorateDecoratedSuite  sb    
 }} )$0FGG"+M8;QRRox/Em/T/TUUUUUr   c                    |                                  }t          j        |g          }t          j        |t          j                  }|                     |t          j        t          j        |          g                     dS )z
        Tests can be in non-standard suites. L{decorate} preserves the
        non-standard suites when it decorates the tests.
        N)r~  r	   DestructiveTestSuiter
   r  r  r  )r   rA   r   	decorateds       r   test_decoratePreservesSuitez.TestDecoratorMixin.test_decoratePreservesSuite  sx    
 }}+TF33%eX-CDD	v2H4J44P4P3QRR	
 	
 	
 	
 	
r   N)r-   r.   r/   r0   r  r  r  r  r  r  r  r  r  r  r  r1   r   r   r  r  1  s         	5 	5 	5B B B: : : : : :"K K K

 

 


 
 
) ) )(8 8 8V V V

 

 

 

 

r   r  c                        e Zd ZdZej        ZdS )SynchronousTestDecoratorTestsz
    Tests for our test decoration features in the synchronous case.

    See L{twisted.trial.test.test_tests.TestDecoratorMixin}
    Nr  r1   r   r   r  r    "          +HHHr   r  c                        e Zd ZdZej        ZdS )AsynchronousTestDecoratorTestsz
    Tests for our test decoration features in the asynchronous case.

    See L{twisted.trial.test.test_tests.TestDecoratorMixin}
    Nr  r1   r   r   r  r    "           HHHr   r  c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	MonkeyPatchMixinzF
    Tests for the patch() helper method in L{unittest.TestCase}.
    c                 l    d| _         d| _        | j         | _        |                                 | _        dS )r6   originalpatchedN)originalValuepatchedValueobjectToPatchr~  rA   r&   s    r   r8   zMonkeyPatchMixin.setUp  s2     (%!/MMOO			r   c                     | j                             | d| j                   |                     | j        | j                   dS )zi
        Calling C{patch()} on a test monkey patches the specified object and
        attribute.
        r  N)rA   patchr  r"   r  r&   s    r   
test_patchzMonkeyPatchMixin.test_patch  sA    
 		ot/@AAA+T->?????r   c                     | j                             | d| j                   | j                             t	          j                               |                     | j        | j                   dS )zw
        Any monkey patches introduced by a test using C{patch()} are reverted
        after the test has run.
        r  N)	rA   r  r  rF   r   r   r"   r  r  r&   s    r   test_patchRestoredAfterRunz+MonkeyPatchMixin.test_patchRestoredAfterRun  s^    
 		ot/@AAA	h'))***+T-?@@@@@r   c                     | j                             | d| j                  }|                                 |                     | j        | j                   dS )z
        C{patch()} return a L{monkey.MonkeyPatcher} object that can be used to
        restore the original values before the end of the test.
        r  N)rA   r  r  restorer"   r  r  r   r  s     r   test_revertDuringTestz&MonkeyPatchMixin.test_revertDuringTest  sM    
 	ot7HII+T-?@@@@@r   c                     | j                             | d| j                  }|                                 |                                 |                     | j        | j                   dS )zq
        The returned L{monkey.MonkeyPatcher} object can re-apply the patch
        during the test run.
        r  N)rA   r  r  r  r"   r  r  s     r   test_revertAndRepatchz&MonkeyPatchMixin.test_revertAndRepatch  sZ    
 	ot7HII+T->?????r   c                    | j                             | d| j                   |                     | j        | j                   | j                             | dd           |                     | j        d           | j                             t          j                               |                     | j        | j                   dS )zW
        Successive patches are applied and reverted just like a single patch.
        r  zsecond valueN)	rA   r  r  r"   r  rF   r   r   r  r&   s    r   test_successivePatchesz'MonkeyPatchMixin.test_successivePatches  s     		ot/@AAA+T->???	o~>>>+^<<<	h'))***+T-?@@@@@r   N)
r-   r.   r/   r0   r8   r  r  r  r  r  r1   r   r   r  r    s         $ $ $@ @ @A A AA A A@ @ @	A 	A 	A 	A 	Ar   r  c                        e Zd ZdZej        ZdS )SynchronousMonkeyPatchTestsz
    Tests for the patch() helper method in the synchronous case.

    See L{twisted.trial.test.test_tests.MonkeyPatchMixin}
    Nr  r1   r   r   r  r    r  r   r  c                        e Zd ZdZej        ZdS )AsynchronousMonkeyPatchTestsz
    Tests for the patch() helper method in the asynchronous case.

    See L{twisted.trial.test.test_tests.MonkeyPatchMixin}
    Nr  r1   r   r   r  r  (  r  r   r  c                   *    e Zd ZdZd Zd Zd Zd ZdS )IterateTestsMixinz]
    L{_iterateTests} returns a list of all test cases in a test suite or test
    case.
    c                     |                                  }|                     |gt          t          |                               dS )zj
        L{_iterateTests} on a single test case returns a list containing that
        test case.
        N)r~  r"   r  r   rG   s     r   test_iterateTestCasez&IterateTestsMixin.test_iterateTestCase8  s?    
 }}$mD&9&9!:!:;;;;;r   c                     |                                  }t          j        |g          }|                     |gt	          t          |                               dS )z
        L{_iterateTests} on a test suite that contains a single test case
        returns a list containing that test case.
        Nr~  r	   r|  r"   r  r   r   rA   r   s      r   test_iterateSingletonTestSuitez0IterateTestsMixin.test_iterateSingletonTestSuite@  sQ    
 }} $(($mE&:&:!;!;<<<<<r   c                     |                                  }t          j        t          j        |g          g          }|                     |gt	          t          |                               dS )zP
        L{_iterateTests} returns tests that are in nested test suites.
        Nr  r  s      r   test_iterateNestedTestSuitez-IterateTestsMixin.test_iterateNestedTestSuiteI  s_     }} &"2D6":":!;<<$mE&:&:!;!;<<<<<r   c                     |                                  }t          j        t          j        |g          | g          }|                     || gt	          t          |                               dS )zU
        L{_iterateTests} returns tests in left-to-right, depth-first order.
        Nr  r  s      r   #test_iterateIsLeftToRightDepthFirstz5IterateTestsMixin.test_iterateIsLeftToRightDepthFirstQ  sc     }} &"2D6":":D!ABB$tM%,@,@'A'ABBBBBr   N)r-   r.   r/   r0   r  r  r  r  r1   r   r   r  r  2  s_         
< < <= = == = =C C C C Cr   r  c                        e Zd ZdZej        ZdS )SynchronousIterateTestsTestsz
    Check that L{_iterateTests} returns a list of all test cases in a test suite
    or test case for synchronous tests.

    See L{twisted.trial.test.test_tests.IterateTestsMixin}
    Nr  r1   r   r   r  r  Z  r  r   r  c                        e Zd ZdZej        ZdS )AsynchronousIterateTestsTestsz
    Check that L{_iterateTests} returns a list of all test cases in a test suite
    or test case for asynchronous tests.

    See L{twisted.trial.test.test_tests.IterateTestsMixin}
    Nr  r1   r   r   r  r  e  r  r   r  c                       e Zd ZdZd Zd ZdS )TrialGeneratorFunctionTestsz=
    Tests for generator function methods in test cases.
    c                     G d dt           j                  } |d          }t          j                    }|                    |           |                     t          |j                  d           |                     t          |j                  d           | 	                    d|j        d         d         j
        j        d                    | 	                    d|j        d         d         j
        j        d                    | 	                    d|j        d         d         j
        j        d                    d	S )
z
        In a TestCase, a test method which is a generator function is reported
        as an error, as such a method will never run assertions.
        c                       e Zd ZdZd ZdS )TTrialGeneratorFunctionTests.test_errorOnGeneratorFunction.<locals>.GeneratorTestCasez?
            A fake TestCase for testing purposes.
            c              3   <   K   |                      d           dV  dS zt
                A method which is also a generator function, for testing
                purposes.
                zthis should never be reachedNrW  r&   s    r   test_generatorzcTrialGeneratorFunctionTests.test_errorOnGeneratorFunction.<locals>.GeneratorTestCase.test_generator  (      
 		8999r   Nr-   r.   r/   r0   r  r1   r   r   GeneratorTestCaser  {  -             r   r  r  r   r<   z GeneratorTestCase.test_generatorz+GeneratorTestCase testMethod=test_generator4is a generator function and therefore will never runN)r
   r~  r   r   rF   r"   rd   r$   r#   assertInr   args)r   r  testCaser7   s       r   test_errorOnGeneratorFunctionz9TrialGeneratorFunctionTests.test_errorOnGeneratorFunctionu  sH   	 	 	 	 	 1 	 	 	 %$%566$&&VV_--q111V]++Q///.a0@0C0I0Nq0Q	
 	
 	
 	9M!Q%*1-	
 	
 	
 	BM!Q%*1-	
 	
 	
 	
 	
r   c                     G d dt           j                  } |d          }t          j                    }|                    |           |                     t          |j                  d           |                     t          |j                  d           | 	                    d|j        d         d         j
        j        d                    | 	                    d|j        d         d         j
        j        d                    | 	                    d|j        d         d         j
        j        d                    d	S )
z
        In a SynchronousTestCase, a test method which is a generator function
        is reported as an error, as such a method will never run assertions.
        c                       e Zd ZdZd ZdS )rTrialGeneratorFunctionTests.test_synchronousTestCaseErrorOnGeneratorFunction.<locals>.GeneratorSynchronousTestCasezJ
            A fake SynchronousTestCase for testing purposes.
            c              3   <   K   |                      d           dV  dS r  r  r&   s    r   r  zTrialGeneratorFunctionTests.test_synchronousTestCaseErrorOnGeneratorFunction.<locals>.GeneratorSynchronousTestCase.test_generator  r  r   Nr  r1   r   r   GeneratorSynchronousTestCaser    r  r   r  r  r   r<   z+GeneratorSynchronousTestCase.test_generatorz6GeneratorSynchronousTestCase testMethod=test_generatorr  N)r
   r%  r   r   rF   r"   rd   r$   r#   r  r   r  )r   r  r  r7   s       r   0test_synchronousTestCaseErrorOnGeneratorFunctionzLTrialGeneratorFunctionTests.test_synchronousTestCaseErrorOnGeneratorFunction  sI   	 	 	 	 	8+G 	 	 	 0/0@AA$&&VV_--q111V]++Q///9M!Q%*1-	
 	
 	
 	DM!Q%*1-	
 	
 	
 	BM!Q%*1-	
 	
 	
 	
 	
r   N)r-   r.   r/   r0   r  r  r1   r   r   r  r  p  s=         "
 "
 "
H#
 #
 #
 #
 #
r   r  )Ir0   rN   r  r
   r   rL   ior   twisted.internetr   r   twisted.python.compatr   twisted.python.reflectr   twisted.trialr   r	   r   twisted.trial._asyncrunnerr   r   r   r3  r   #twisted.trial.test.test_suppressionr   r   r3   r%  rS   r~  rX   rZ   r{   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r'  r+  r/  rC  rm  ro  rz  r  r  r  r  r  r  r  r  r  r  r  r  r1   r   r   <module>r     s~	   * 
			 



            + + + + + + + + ' ' ' ' ' ' + + + + + + : : : : : : : : : : : :         
 ) ( ( ( ( ( @ @ @ @ @ @; ; ; ; ; ; ; ;@8* 8* 8* 8* 8* 8* 8* 8*v    lH,H       |X->   F
 F
 F
 F
 F
' F
 F
 F
R    !183O       "2H4E   08 08 08 08 08' 08 08 08fS S S S S 0(2N S S ST T T T T!183D T T TU5 U5 U5 U5 U5  U5 U5 U5p	S 	S 	S 	S 	S9h&B 	S 	S 	S	T 	T 	T 	T 	TIx'8 	T 	T 	T48 48 48 48 48% 48 48 48nM M M M M0L M M MN N N N N1B N N N49 49 49 49 49& 49 49 49nO O O O O(2N O O OP P P P P/83D P P P(H (H (H (H (H(6 (H (H (HV0' 0' 0' 0' 0' 0' 0' 0'f    lH,H   $    |X->   $    #3X5F   ,4& 4& 4& 4& 4& 4& 4& 4&nM M M M MGX-I M M M
 
 
 
 
Wh&B 
 
 
$4! 4! 4! 4! 4!X9 4! 4! 4!nd. d. d. d. d. d. d. d.NO O O O O(2N O O OX X X X X/83D X X X64 4 4 4 4 4 4 4B, , , , ,$68T , , ,! ! ! ! !%79J ! ! !X
 X
 X
 X
 X
 X
 X
 X
v, , , , ,$68T , , ,! ! ! ! !%79J ! ! !;A ;A ;A ;A ;A ;A ;A ;A|, , , , ,"2H4P , , ,! ! ! ! !#3X5F ! ! !%C %C %C %C %C %C %C %CP, , , , ,#4h6R , , ,! ! ! ! !$5x7H ! ! !L
 L
 L
 L
 L
("> L
 L
 L
 L
 L
r   