
    Vh              	          d Z ddlZddlZddl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 ddlmZ  G d d	ej"                        Z e	ej$                         G d
 d ej&                  ej$                  d                   Zd Zd Z G d de      Z G d de      Z G d de      Z ej4                  eej6                  ej$                          ej4                  eej8                  ej$                          eedd      Zer ej4                  eeej$                         deej6                  ej"                  f   deej$                     fdZy)z-
Infrastructure for test running and suites.
    N)IteratorUnion)implementer)
components)itrialreporter)_logObserverc                       e Zd ZdZd Zy)	TestSuitezh
    Extend the standard library's C{TestSuite} with a consistently overrideable
    C{run} method.
    c                 V    | j                   D ]  }|j                  r |S  ||        |S )z;
        Call C{run} on every member of the suite.
        )_tests
shouldStop)selfresulttests      J/home/dcms/DCMS/lib/python3.12/site-packages/twisted/trial/_asyncrunner.pyrunzTestSuite.run   s8     KK 	D   L	     N__name__
__module____qualname____doc__r    r   r   r   r      s    
r   r   c                       e Zd ZdZd Zd Zy)TestDecoratorz
    Decorator for test cases.

    @param _originalTest: The wrapped instance of test.
    @type _originalTest: A provider of L{itrial.ITestCase}
    c                 $    | j                  |      S zQ
        Run the unit test.

        @param result: A TestResult object.
        )r   r   r   s     r   __call__zTestDecorator.__call__4   s     xxr   c                 t    | j                   j                  t        j                  || j                              S r   )_originalTestr   r   _AdaptedReporter	__class__r   s     r   r   zTestDecorator.run<   s,     !!%%h&?&?&WXXr   N)r   r   r   r   r    r   r   r   r   r   r   '   s     Yr   r   r"   c                     g | _         y)z
    Clear all tests from C{suite}.

    This messes with the internals of C{suite}. In particular, it assumes that
    the suite keeps all of its tests in a list in an instance variable called
    C{_tests}.
    N)r   )suites    r   _clearSuiter'   E   s     ELr   c                     	 t        |       }t        |        |D ]  }| j                  t	        ||              | S # t        $ r  ||       cY S w xY w)a2  
    Decorate all test cases in C{test} with C{decorator}.

    C{test} can be a test case or a test suite. If it is a test suite, then the
    structure of the suite is preserved.

    L{decorate} tries to preserve the class of the test suites it finds, but
    assumes the presence of the C{_tests} attribute on the suite.

    @param test: The C{TestCase} or C{TestSuite} to decorate.

    @param decorator: A unary callable used to decorate C{TestCase}s.

    @return: A decorated C{TestCase} or a C{TestSuite} containing decorated
        C{TestCase}s.
    )iter	TypeErrorr'   addTestdecorate)r   	decoratortestscases       r   r,   r,   P   s\    $T

  0XdI./0K  s   < AAc                       e Zd ZdZy)_PyUnitTestCaseAdapterz2
    Adapt from pyunit.TestCase to ITestCase.
    N)r   r   r   r   r   r   r   r1   r1   o   s    r   r1   c                       e Zd ZdZd Zy)_BrokenIDTestCaseAdapterz
    Adapter for pyunit-style C{TestCase} subclasses that have undesirable id()
    methods. That is C{unittest.FunctionTestCase} and C{unittest.DocTestCase}.
    c                 r    | j                   j                         }||S | j                   j                         S )zH
        Return the fully-qualified Python name of the doctest.
        )r"   shortDescriptionid)r   testIDs     r   r6   z_BrokenIDTestCaseAdapter.id{   s8     ##446M!!$$&&r   N)r   r   r   r   r6   r   r   r   r3   r3   u   s    
'r   r3   c                       e Zd ZdZd Zy) _ForceGarbageCollectionDecoratorz
    Forces garbage collection to be run before and after the test. Any errors
    logged during the post-test collection are added to the test result as
    errors.
    c                 N   t        j                          t        j                  | |       t	        j
                          t        j                          t	        j                         D ]  }|j                  | |        t	        j                          t	        j                          y )N)
gccollectr   r   r	   _add	getErrorsaddErrorflushErrors_remove)r   r   errors      r   r   z$_ForceGarbageCollectionDecorator.run   sn    


$'


!++- 	)EOOD%(	)  "r   Nr   r   r   r   r9   r9      s    r   r9   DocTestCasetestSuiteOrCasereturnc              #      K   	 t        |       }|D ]  }t        |      E d{     y7 # t        $ r |  Y yw xY ww)zF
    Iterate through all of the test cases in C{testSuiteOrCase}.
    N)r)   _iterateTestsr*   )rD   r&   r   s      r   rG   rG      sM     +_%  	+D$T***	+*	  s$   ?, ?*?<?<?) r   doctestr;   unittestpyunittypingr   r   zope.interfacer   twisted.pythonr   twisted.trialr   r   twisted.trial._synctestr	   r   	ITestCaseproxyForInterfacer   r'   r,   r1   r3   r9   registerAdapterTestCaseFunctionTestCasegetattr_docTestCaserG   r   r   r   <module>rW      sO  

  	  " & % * 0   " VY J  /Y Y:>] '5 ' } $ 
  16??FDTDT U 
  f55v7G7G
 wt4J7vGWGWX+6??F,<,<<=+f+r   