
    Vh                     t    d Z ddlZddlmZ ddlmZ ddlmZ  G d d      Z G d d	eej                        Z
y)
z2
Tests for warning suppression features of Trial.
    N)namedAny)unittest)suppressionc                   F    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)SuppressionMixinzj
    Tests for the warning suppression features of
    L{twisted.trial.unittest.SynchronousTestCase}.
    c                 J    |j                  t        j                                y )N)runpyunit
TestResult)selfsuites     S/home/dcms/DCMS/lib/python3.12/site-packages/twisted/trial/test/test_suppression.pyrunTestszSuppressionMixin.runTests   s    		&##%&    c                 :    t        j                   ||      g      S )z
        Return a new L{unittest.TestSuite} with a single test method in it.

        @param cls: A L{TestCase} subclass defining a test method.

        @param methodName: The name of the test method from C{cls}.
        )r
   	TestSuite)r   cls
methodNames      r   _loadzSuppressionMixin._load   s     Z 122r   c                 T    | j                  |D cg c]  }|d   	 c}|       yc c}w )a&  
        Assert that a certain number of warnings with certain messages were
        emitted in a certain order.

        @param warnings: A list of emitted warnings, as returned by
            C{flushWarnings}.

        @param which: A list of strings giving warning messages that should
            appear in C{warnings}.

        @raise self.failureException: If the warning messages given by C{which}
            do not match the messages in the warning information in C{warnings},
            or if they do not appear in the same order.
        messageN)assertEqual)r   warningswhichwarnings       r   _assertWarningsz SuppressionMixin._assertWarnings#   s'     	HE'),EuMEs   %c                 B   | j                  | j                  | j                  d             | j                  | j                  j                  g      }| j                  |t        j                  t        j                  t        j                  t        j                  g       y)z
        Suppressions defined by the test method being run are applied to any
        warnings emitted while running the C{setUp} fixture.
        testSuppressMethodN)	r   r   TestSetUpSuppressionflushWarnings_emitr   r   CLASS_WARNING_MSGMODULE_WARNING_MSGr   warningsShowns     r   test_setUpSuppressionz&SuppressionMixin.test_setUpSuppression4   s{    
 	djj!:!:<PQR**D,E,E,K,K+LM--..--..		
r   c                 B   | j                  | j                  | j                  d             | j                  | j                  j                  g      }| j                  |t        j                  t        j                  t        j                  t        j                  g       y)z
        Suppressions defined by the test method being run are applied to any
        warnings emitted while running the C{tearDown} fixture.
        r   N)	r   r   TestTearDownSuppressionr    r!   r   r   r"   r#   r$   s     r   test_tearDownSuppressionz)SuppressionMixin.test_tearDownSuppressionE   s{    
 	djj!=!=?STU**D,H,H,N,N+OP--..--..		
r   c                    | j                  | j                  | j                  d             | j                  | j                  j                  g      }| j                  |t        j                  t        j                  g       y)z
        A suppression set on a test method prevents warnings emitted by that
        test method which the suppression matches from being emitted.
        r   N)	r   r   TestSuppressionr    r!   r   r   r"   r#   r$   s     r   test_suppressMethodz$SuppressionMixin.test_suppressMethodV   sf    
 	djj!5!57KLM**D,@,@,F,F+GH**K,J,JK	
r   c                 t   | j                  | j                  | j                  d             | j                  | j                  j                  g      }| j                  |d   d   t        j                         | j                  |d   d   t        j                         | j                  t        |      d       y)z
        A suppression set on a L{SynchronousTestCase} subclass prevents warnings
        emitted by any test methods defined on that class which match the
        suppression from being emitted.
        testSuppressClassr   r         N)
r   r   r+   r    r!   r   r   METHOD_WARNING_MSGr#   lenr$   s     r   test_suppressClassz#SuppressionMixin.test_suppressClassb   s     	djj!5!57JKL**D,@,@,F,F+GHq))4k6T6TUq))4k6T6TU]+Q/r   c                 t   | j                  | j                  | j                  d             | j                  | j                  j
                  g      }| j                  |d   d   t        j                         | j                  |d   d   t        j                         | j                  t        |      d       y)z
        A suppression set on a module prevents warnings emitted by any test
        mewthods defined in that module which match the suppression from being
        emitted.
        testSuppressModuler   r   r/   r0   N)r   r   TestSuppression2r    r+   r!   r   r   r1   r"   r2   r$   s     r   test_suppressModulez$SuppressionMixin.test_suppressModulen   s     	djj!6!68LMN**D,@,@,F,F+GHq))4k6T6TUq))4k6S6ST]+Q/r   c                    | j                  | j                  | j                  d             | j                  | j                  j                  g      }| j                  |d   d   t        j                         | j                  |d   d   t        j                         | j                  |d   d   t        j                         | j                  t        |      d       y)z
        The suppression set on a test method completely overrides a suppression
        with wider scope; if it does not match a warning emitted by that test
        method, the warning is emitted, even if a wider suppression matches.
        testOverrideSuppressClassr   r   r/   r0      N)r   r   r+   r    r!   r   r   r1   r"   r#   r2   r$   s     r   test_overrideSuppressClassz+SuppressionMixin.test_overrideSuppressClassz   s     	djj!5!57RST**D,@,@,F,F+GHq))4k6T6TUq))4k6S6STq))4k6T6TU]+Q/r   N)__name__
__module____qualname____doc__r   r   r   r&   r)   r,   r3   r7   r;    r   r   r   r      s5    
'3N"
"
"


0
00r   r   c                   P    e Zd ZdZ ed      Z ed      Z ed      Z ed      Zy)SynchronousSuppressionTestsz0
    @see: L{twisted.trial.test.test_tests}
    z>twisted.trial.test.suppression.SynchronousTestSetUpSuppressionzAtwisted.trial.test.suppression.SynchronousTestTearDownSuppressionz9twisted.trial.test.suppression.SynchronousTestSuppressionz:twisted.trial.test.suppression.SynchronousTestSuppression2N)	r<   r=   r>   r?   r   r   r(   r+   r6   r@   r   r   rB   rB      sF     $H 'K CO  Dr   rB   )r?   r   r
   twisted.python.reflectr   twisted.trialtwisted.trial.testr   r   SynchronousTestCaserB   r@   r   r   <module>rG      s:   
  + " *u0 u0p"2H4P4P r   