Ë
    oj  ã                   ó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     úE/usr/lib/python3/dist-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°˜' )Ó,ÒEÀuÕ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{   € ð
 	�‰�d—j‘j ×!:Ñ!:Ð<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{   € ð
 	�‰�d—j‘j ×!=Ñ!=Ð?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   € ð
 	�‰�d—j‘j ×!5Ñ!5Ð7KÓ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–   € ð 	�‰�d—j‘j ×!5Ñ!5Ð7JÓKÔLØ×*Ñ*¨D×,@Ñ,@×,FÑ,FÐ+GÓHˆØ×Ñ˜ qÑ)¨)Ñ4´k×6TÑ6TÔUØ×Ñ˜ qÑ)¨)Ñ4´k×6TÑ6TÔ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–   € ð 	�‰�d—j‘j ×!6Ñ!6Ð8LÓMÔNØ×*Ñ*¨D×,@Ñ,@×,FÑ,FÐ+GÓHˆØ×Ñ˜ qÑ)¨)Ñ4´k×6TÑ6TÔUØ×Ñ˜ qÑ)¨)Ñ4´k×6SÑ6SÔ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¶   € ð 	�‰�d—j‘j ×!5Ñ!5Ð7RÓSÔTØ×*Ñ*¨D×,@Ñ,@×,FÑ,FÐ+GÓHˆØ×Ñ˜ qÑ)¨)Ñ4´k×6TÑ6TÔUØ×Ñ˜ qÑ)¨)Ñ4´k×6SÑ6SÔTØ×Ñ˜ qÑ)¨)Ñ4´k×6TÑ6TÔ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0ôpÐ"2°H×4PÑ4Põ r   