
    h              	          S r SSKrSSKrSSKrSSKJrJr  SSKJ	r	  SSK
Jr  SSKJrJr  SSKJr   " S S	\R"                  5      r\	" \R$                  5       " S
 S\R&                  " \R$                  S5      5      5       rS rS r " S S\5      r " S S\5      r " S S\5      r\R4                  " \\R6                  \R$                  5        \R4                  " \\R8                  \R$                  5        \" \SS5      r\(       a  \R4                  " \\\R$                  5        S\\R6                  \R"                  4   S\\R$                     4S jrg)z-
Infrastructure for test running and suites.
    N)IteratorUnion)implementer)
components)itrialreporter)_logObserverc                       \ rS rSrSrS rSrg)	TestSuite   z\
Extend the standard library's C{TestSuite} with a consistently overrideable
C{run} method.
c                 d    U R                    H  nUR                  (       a    U$ U" U5        M!     U$ )z+
Call C{run} on every member of the suite.
)_tests
shouldStop)selfresulttests      a/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/trial/_asyncrunner.pyrunTestSuite.run   s3     KKD   L        N__name__
__module____qualname____firstlineno____doc__r   __static_attributes__r   r   r   r   r      s    
r   r   c                   $    \ rS rSrSrS rS rSrg)TestDecorator'   z
Decorator for test cases.

@param _originalTest: The wrapped instance of test.
@type _originalTest: A provider of L{itrial.ITestCase}
c                 $    U R                  U5      $ z9
Run the unit test.

@param result: A TestResult object.
)r   r   r   s     r   __call__TestDecorator.__call__4   s     xxr   c                 t    U R                   R                  [        R                  " XR                  5      5      $ r#   )_originalTestr   r   _AdaptedReporter	__class__r$   s     r   r   TestDecorator.run<   s*     !!%%h&?&?&WXXr   r   N)r   r   r   r   r   r%   r   r   r   r   r   r    r    '   s     Yr   r    r(   c                     / U l         g)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                      [        U 5      n[        U 5        U H  nU R                  [	        X15      5        M     U $ ! [         a    U" U 5      s $ f = f)a
  
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   r3   r3   P   sU    $T

 Xd./ K  s   = AAc                       \ rS rSrSrSrg)_PyUnitTestCaseAdaptero   z*
Adapt from pyunit.TestCase to ITestCase.
r   N)r   r   r   r   r   r   r   r   r   r8   r8   o   s    r   r8   c                       \ rS rSrSrS rSrg)_BrokenIDTestCaseAdapteru   z
Adapter for pyunit-style C{TestCase} subclasses that have undesirable id()
methods. That is C{unittest.FunctionTestCase} and C{unittest.DocTestCase}.
c                 t    U R                   R                  5       nUb  U$ U R                   R                  5       $ )z8
Return the fully-qualified Python name of the doctest.
)r(   shortDescriptionid)r   testIDs     r   r?   _BrokenIDTestCaseAdapter.id{   s8     ##446M!!$$&&r   r   N)r   r   r   r   r   r?   r   r   r   r   r;   r;   u   s    
'r   r;   c                       \ rS rSrSrS rSrg) _ForceGarbageCollectionDecorator   z
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                 Z   [         R                  " 5         [        R                  X5        [        R
                  " 5         [         R                  " 5         [        R                  " 5        H  nUR                  X5        M     [        R                  " 5         [        R                  " 5         g )N)
gccollectr    r   r	   _add	getErrorsaddErrorflushErrors_remove)r   r   errors      r   r   $_ForceGarbageCollectionDecorator.run   se    


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


!++-EOOD( .  "r   r   Nr   r   r   r   rC   rC      s    r   rC   DocTestCasetestSuiteOrCasereturnc              #      #     [        U 5      nU H  n[        U5       Sh  vN   M     g N	! [         a    U v    gf = f7f)z>
Iterate through all of the test cases in C{testSuiteOrCase}.
N)r0   _iterateTestsr1   )rP   r-   r   s      r   rS   rS      sG     +_% D$T*** *	  s)   A. A,
A?A?A) r   doctestrF   unittestpyunittypingr   r   zope.interfacer   twisted.pythonr   twisted.trialr   r   twisted.trial._synctestr	   r   	ITestCaseproxyForInterfacer    r.   r3   r8   r;   rC   registerAdapterTestCaseFunctionTestCasegetattr_docTestCaserS   r   r   r   <module>rc      sG  

  	  " & % * 0   " VY  /Y Y:>] '5 ' } $   16??FDTDT U   f55v7G7G
 wt47vGWGWX+6??F,<,<<=+f+r   