o
    Óó·iÍ  ã                   @   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r�e 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.
        N)Ú_testsZ
shouldStop)ÚselfÚresultÚtest© r   ú`C:\Users\psant\Downloads\PAF backend\school\venv\Lib\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.
        N)r   ©r   r   r   r   r   Ú__call__4   s   
zTestDecorator.__call__c                 C   s   | j  t || j¡¡S r   )Ú_originalTestr   r   Z_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.
    N)ÚiterÚ	TypeErrorr   Z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   ZshortDescriptionÚid)r   Z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)
ÚgcZcollectr   r   r   Z_addZ	getErrorsZaddErrorZflushErrorsÚ_remove)r   r   Úerrorr   r   r   r   Œ   s   z$_ForceGarbageCollectionDecorator.runNr   r   r   r   r   r)   …   s    r)   Z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)r-   r   r   r   r   r   r/   ¤   s   €ÿÿr/   ) r   Údoctestr*   ZunittestZpyunitÚtypingr   r   Zzope.interfacer   Ztwisted.pythonr   Ztwisted.trialr   r   Ztwisted.trial._synctestr   r
   Z	ITestCaseZproxyForInterfacer   r   r"   r&   r'   r)   ZregisterAdapterZTestCaseZFunctionTestCaseÚgetattrZ_docTestCaser/   r   r   r   r   Ú<module>   sB   
ÿÿ
ÿÿþ