
    tf                     x    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
dS )
z2
Tests for warning suppression features of Trial.
    N)namedAny)unittest)suppressionc                   H    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S )SuppressionMixinzj
    Tests for the warning suppression features of
    L{twisted.trial.unittest.SynchronousTestCase}.
    c                 R    |                     t          j                               d S )N)runpyunit
TestResult)selfsuites     b/var/www/surfInsights/venv3-11/lib/python3.11/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22r   c                 F    |                      d |D             |           dS )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.
        c                     g | ]
}|d          S )message ).0warnings     r   
<listcomp>z4SuppressionMixin._assertWarnings.<locals>.<listcomp>2   s    EEE'),EEEr   N)assertEqual)r   warningswhichs      r   _assertWarningsz SuppressionMixin._assertWarnings#   s/     	EEHEEEuMMMMMr   c                 &   |                      |                     | j        d                     |                     | j        j        g          }|                     |t          j        t          j        t          j        t          j        g           dS )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QRRR**D,E,K+LMM-.-.		
 	
 	
 	
 	
r   c                 &   |                      |                     | j        d                     |                     | j        j        g          }|                     |t          j        t          j        t          j        t          j        g           dS )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TUUU**D,H,N+OPP-.-.		
 	
 	
 	
 	
r   c                     |                      |                     | j        d                     |                     | j        j        g          }|                     |t          j        t          j        g           dS )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   sw    
 	djj!57KLLMMM**D,@,F+GHH*K,JK	
 	
 	
 	
 	
r   c                    |                      |                     | j        d                     |                     | j        j        g          }|                     |d         d         t          j                   |                     |d         d         t          j                   |                     t          |          d           dS )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!57JKKLLL**D,@,F+GHHq))4k6TUUUq))4k6TUUU]++Q/////r   c                    |                      |                     | j        d                     |                     | j        j        g          }|                     |d         d         t          j                   |                     |d         d         t          j	                   |                     t          |          d           dS )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   r3   r4   N)r   r   TestSuppression2r$   r/   r%   r   r   r5   r&   r6   r(   s     r   test_suppressModulez$SuppressionMixin.test_suppressModulen   s     	djj!68LMMNNN**D,@,F+GHHq))4k6TUUUq))4k6STTT]++Q/////r   c                    |                      |                     | j        d                     |                     | j        j        g          }|                     |d         d         t          j                   |                     |d         d         t          j                   |                     |d         d         t          j	                   |                     t          |          d           dS )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   r3   r4      N)r   r   r/   r$   r%   r   r   r5   r&   r'   r6   r(   s     r   test_overrideSuppressClassz+SuppressionMixin.test_overrideSuppressClassz   s     	djj!57RSSTTT**D,@,F+GHHq))4k6TUUUq))4k6STTTq))4k6TUUU]++Q/////r   N)__name__
__module____qualname____doc__r   r   r    r*   r-   r0   r7   r;   r?   r   r   r   r   r      s         
' ' '3 3 3N N N"
 
 
"
 
 
"

 

 


0 
0 
0
0 
0 
00 0 0 0 0r   r   c                   j    e Zd ZdZ ed          Z ed          Z ed          Z ed          ZdS )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@   rA   rB   rC   r   r#   r,   r/   r:   r   r   r   rE   rE      su          $8H  'hK  hC O  xD r   rE   )rC   r   r
   twisted.python.reflectr   twisted.trialtwisted.trial.testr   r   SynchronousTestCaserE   r   r   r   <module>rJ      s    
     + + + + + + " " " " " " * * * * * *u0 u0 u0 u0 u0 u0 u0 u0p    "2H4P     r   