
    \d              	       b   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j        eej        ej                    ej        eej        ej                    eedd          Zer ej        eeej                   deej        ej        f         deej                 fdZdS )z-
Infrastructure for test running and suites.
    N)IteratorUnion)implementer)
components)itrialreporter)_logObserverc                       e Zd ZdZd ZdS )	TestSuitezh
    Extend the standard library's C{TestSuite} with a consistently overrideable
    C{run} method.
    c                 B    | j         D ]}|j        r n ||           |S )z;
        Call C{run} on every member of the suite.
        )_tests
shouldStop)selfresulttests      :lib/python3.11/site-packages/twisted/trial/_asyncrunner.pyrunzTestSuite.run   s9     K 	 	D  DLLLL    N__name__
__module____qualname____doc__r    r   r   r   r      s-         
    r   r   c                       e Zd ZdZd Zd ZdS )TestDecoratorz
    Decorator for test cases.

    @param _originalTest: The wrapped instance of test.
    @type _originalTest: A provider of L{itrial.ITestCase}
    c                 ,    |                      |          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                 f    | j                             t          j        || j                            S r   )_originalTestr   r   _AdaptedReporter	__class__r   s     r   r   zTestDecorator.run<   s*     !%%h&?&W&WXXXr   N)r   r   r   r   r    r   r   r   r   r   r   '   sA              Y Y Y Y Yr   r   r"   c                     g | _         dS )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     ELLLr   c                     	 t          |           }n# t          $ r  ||           cY S w xY wt          |            |D ]%}|                     t	          ||                     &| S )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

   y  0 0XdI..////Ks    **c                       e Zd ZdZdS )_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dS )_BrokenIDTestCaseAdapterz
    Adapter for pyunit-style C{TestCase} subclasses that have undesirable id()
    methods. That is C{unittest.FunctionTestCase} and C{unittest.DocTestCase}.
    c                 n    | j                                         }||S | 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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dS ) _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                 R   t          j                     t                              | |           t	          j                     t          j                     t	          j                    D ]}|                    | |           t	          j                     t	          j	                     d S )N)
gccollectr   r   r	   _add	getErrorsaddErrorflushErrors_remove)r   r   errors      r   r   z$_ForceGarbageCollectionDecorator.run   s    

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

!+-- 	) 	)EOOD%(((( """r   Nr   r   r   r   r9   r9      s-             r   r9   DocTestCasetestSuiteOrCasereturnc              #      K   	 t          |           }|D ]}t          |          E d{V  dS # t          $ r | V  Y dS w xY w)zF
    Iterate through all of the test cases in C{testSuiteOrCase}.
    N)r)   _iterateTestsr*   )rD   r&   r   s      r   rG   rG      s      +_%%  	+ 	+D$T**********	+ 	+    s   / A A) 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      s  
 
  				     " " " " " " " " & & & & & & % % % % % % * * * * * * * * 0 0 0 0 0 0        " VY Y Y Y Y J / Y Y Y:    >    ]   ' ' ' ' '5 ' ' '     }   $ 
 16?FDT U U U 
 f5v7G  
 wwt44 YJ7vGWXXX+6?F,<<=+f+ + + + + +r   