o
    >h                     @   sB  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	 d	ejZe	ejG d
d deejdZdd Zdd ZG dd deZG dd deZG dd deZeeejej eeejej eeddZereeeej deejejf deej fd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d ZdS )	TestSuitezh
    Extend the standard library's C{TestSuite} with a consistently overrideable
    C{run} method.
    c                 C   s$   | j D ]}|jr |S || q|S )z;
        Call C{run} on every member of the suite.
        )_tests
shouldStop)selfresulttest r   z/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/trial/_asyncrunner.pyrun   s   

zTestSuite.runN__name__
__module____qualname____doc__r   r   r   r   r   r
          r
   c                   @   s    e Zd ZdZdd Zd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                 C   s
   |  |S zQ
        Run the unit test.

        @param result: A TestResult object.
        )r   r   r   r   r   r   __call__4   s   
zTestDecorator.__call__c                 C   s   | j t|| jS r   )_originalTestr   r   _AdaptedReporter	__class__r   r   r   r   r   <   s   zTestDecorator.runN)r   r   r   r   r   r   r   r   r   r   r   '   s    r   r   c                 C   s
   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   )suiter   r   r   _clearSuiteE   s   
r!   c                 C   sN   zt | }W n ty   ||  Y S w t|  |D ]
}| t|| q| 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caser   r   r   r%   P   s   r%   c                   @   s   e Zd ZdZdS )_PyUnitTestCaseAdapterz2
    Adapt from pyunit.TestCase to ITestCase.
    N)r   r   r   r   r   r   r   r   r)   o   s    r)   c                   @   r	   )_BrokenIDTestCaseAdapterz
    Adapter for pyunit-style C{TestCase} subclasses that have undesirable id()
    methods. That is C{unittest.FunctionTestCase} and C{unittest.DocTestCase}.
    c                 C   s    | j  }|dur|S | j  S )zH
        Return the fully-qualified Python name of the doctest.
        N)r   shortDescriptionid)r   testIDr   r   r   r,   {   s   

z_BrokenIDTestCaseAdapter.idN)r   r   r   r   r,   r   r   r   r   r*   u   r   r*   c                   @   r	   ) _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                 C   sR   t   t| | t  t   t D ]}|| | qt  t	  d S )N)
gccollectr   r   r   _add	getErrorsaddErrorflushErrors_remove)r   r   errorr   r   r   r      s   z$_ForceGarbageCollectionDecorator.runNr   r   r   r   r   r.      s    r.   DocTestCasetestSuiteOrCasereturnc                 c   sF    zt | }W n ty   | V  Y dS w |D ]	}t|E dH  qdS )zF
    Iterate through all of the test cases in C{testSuiteOrCase}.
    N)r"   r#   _iterateTests)r8   r    r   r   r   r   r:      s   r:   ) r   doctestr/   unittestpyunittypingr   r   zope.interfacer   twisted.pythonr   twisted.trialr   r   twisted.trial._synctestr   r
   	ITestCaseproxyForInterfacer   r!   r%   r)   r*   r.   registerAdapterTestCaseFunctionTestCasegetattr_docTestCaser:   r   r   r   r   <module>   sB   

