HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/trial/__pycache__/runner.cpython-38.pyc
U

�`�[:��@s�dZddlmZmZddddddd	d
ddd
ddddgZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZmZmZmZddlmZmZddlmZddlmZmZddlmZddlmZmZddlm Z m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'e(d�Z)dd�Z*dd
�Z+d d�Z,d!d�Z-d6d"d#�Z.d$d%�Z/d&d'�Z0Gd(d�de%�Z1d)Z2Gd*d�de%�Z3Gd+d
�d
e%�Z4d,d�Z5d-d�Z6e'e�Gd.d�de7��Z8Gd/d�de8�Z9Gd0d�de7�Z:Gd1d2�d2e:�Z;d3d4�Z<e�r�[:e;Z:Gd5d	�d	e7�Z=dS)7zK
A miscellany of code used to run Trial tests.

Maintainer: Jonathan Lange
�)�absolute_import�division�	TestSuite�DestructiveTestSuite�ErrorHolder�LoggedSuite�
TestHolder�
TestLoader�TrialRunner�
TrialSuite�filenameToModule�	isPackage�isPackageDirectory�
isTestCase�name�samefile�NOT_IN_TESTN)�reflect�log�failure�modules�filepath)�_PY3�	_PY35PLUS)�defer)�util�unittest)�	ITestCase)�_ExitWrapper�UncleanWarningsReporterWrapper)� _ForceGarbageCollectionDecorator�
_iterateTests)�_logObserver)r)�implementerrcCs2t|tj�sdStj�tj�|j��d}|dkS)z>Given an object return True if the object looks like a packageFr�__init__)�
isinstance�types�
ModuleType�os�path�splitext�basename�__file__)�moduler+�r.�6/usr/lib/python3/dist-packages/twisted/trial/runner.pyr
2scCs>dd�}|�D]*}d|}tj�tj�||��r|SqdS)z�
    Is the directory at path 'dirname' a Python package directory?
    Returns the name of the __init__ file (it may have a weird extension)
    if dirname is a package directory.  Otherwise, returns False
    cSs6trddl}|j��Sddl}tt|����dSdS�Nr)r�	importlib�	machinery�all_suffixes�imp�list�zipZget_suffixes)r1r4r.r.r/�_getSuffixes@s

z(isPackageDirectory.<locals>._getSuffixesr$F)r(r)�exists�join)�dirnamer7Zext�initFiler.r.r/r:s	

cCstj�|�tj�|�kS)z�
    A hacky implementation of C{os.path.samefile}. Used by L{filenameToModule}
    when the platform doesn't provide C{os.path.samefile}. Do not use this.
    )r(r)�abspath)Z	filename1�	filename2r.r.r/rPsc	Cs�tj�|�std|f��zt�t�|��}Wn ttfk
rNt|�YSXt	|dd�dkrht|�Stj�
|j�dd}t	tjdt�}tj�
|�r�|||�s�tj|j=t|�}|S)aV
    Given a filename, do whatever possible to return a module object matching
    that file.

    If the file in question is a module in Python path, properly import and
    return that module. Otherwise, load the source manually.

    @param fn: A filename.
    @return: A module object.
    @raise ValueError: If C{fn} does not exist.
    z%r doesn't existr,Nrz.pyr)r(r)r8�
ValueErrorr�namedAny�filenameToModuleName�AttributeError�_importFromFile�getattrr*r,r�isfile�sysr�__name__)�fnZretZretFileZsamer.r.r/rXs
c	Cs�t|�}|s(tj�tj�|�d�d}|tjkr<tj|Str�ddl}|j	�
||�}|sbt|��|j	�|�}|j
�|�|tj|<n,ddl}t|d��}|�|||�}W5QRX|S)N���r�r)�_resolveDirectoryr(r)r*�splitrErrr1r�spec_from_file_location�SyntaxError�module_from_spec�loader�exec_moduler4�openZload_source)rGZ
moduleNamer1�specr-r4�fdr.r.r/rB{s"

rBcCs:tj�|�r6t|�}|r(tj�||�}ntd|f��|S)Nz%r is not a package directory)r(r)�isdirrr9r>)rGr;r.r.r/rJ�srJcCsHt|j|jt��|krBt|j�D] }t|j|t��|kr |Sq |jS)z�
    Find the attribute name on the method's class which refers to the method.

    For some methods, notably decorators which have not had __name__ set correctly:

    getattr(method.im_class, method.__name__) != method
    )rC�im_classrF�object�dir)�method�aliasr.r.r/�_getMethodNameInClass�s

rZc@seZdZdZdd�ZdS)rzQ
    A test suite which remove the tests once run, to minimize memory usage.
    cCs(|jr$|jrq$|j�d�}||�q|S)zn
        Almost the same as L{TestSuite.run}, but with C{self._tests} being
        empty at the end.
        r)�_testsZ
shouldStop�pop)�self�result�testr.r.r/�run�s
zDestructiveTestSuite.runN)rF�
__module__�__qualname__�__doc__r`r.r.r.r/r�sz
<not in test>cs eZdZdZ�fdd�Z�ZS)rz[
    Any errors logged in this suite will be reported to the L{TestResult}
    object.
    csNt}|��tt|��|�|��|��D]}|�tt	�|�q,|�
�dS)z�
        Run the suite, storing all errors in C{result}. If an error is logged
        while no tests are running, then it will be added as an error to
        C{result}.

        @param result: A L{TestResult} object.
        N)r"Z_add�superrr`�_removeZ	getErrors�addErrorrrZflushErrors)r]r^Zobserver�error��	__class__r.r/r`�szLoggedSuite.run)rFrarbrcr`�
__classcell__r.r.rhr/r�scs2eZdZdZd
�fdd�	Zdd�Zdd	�Z�ZS)rz�
    Suite to wrap around every single test in a C{trial} run. Used internally
    by Trial to set up things necessary for Trial tests to work, regardless of
    what context they are run in.
    r.FcsJ|r,g}|D]}t�|t�}|�|�q|}t|�}tt|��|g�dS�N)r�decorater �appendrrdrr$)r]�tests�forceGarbageCollectionZnewTestsr_�suiterhr.r/r$�s�zTrialSuite.__init__csHddlm}t���|�dd�fdd��|�d�t�d����dS)Nr)�reactorZafterZshutdowncs
��d�Srk)�callbackr.��dr.r/�<lambda>��z"TrialSuite._bail.<locals>.<lambda>Zmktemp)	�twisted.internetrqrZDeferredZaddSystemEventTriggerZfireSystemEventr�TestCaseZ_wait)r]rqr.rsr/�_bail�s
�
zTrialSuite._bailcCs zt�||�W5|��XdSrk)ryrr`�r]r^r.r.r/r`�szTrialSuite.run)r.F)rFrarbrcr$ryr`rjr.r.rhr/r�scCs@t|�rt�|�}n(z|��}Wntk
r:|j}YnX|S)z�
    @param thing: an object from modules (instance of PythonModule,
        PythonAttribute), a TestCase subclass, or an instance of a TestCase.
    )rr�qual�idrAr)�thingZtheNamer.r.r/rscCs*zt|tj�WStk
r$YdSXdS)z�
    @return: C{True} if C{obj} is a class that contains test cases, C{False}
        otherwise. Used to find all the tests in a module.
    FN)�
issubclass�pyunitrx�	TypeError)�objr.r.r/rsc@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)rz�
    Placeholder for a L{TestCase} inside a reporter. As far as a L{TestResult}
    is concerned, this looks exactly like a unit test.
    NcCs
||_dS)zM
        @param description: A string to be displayed L{TestResult}.
        N��description)r]r�r.r.r/r$*szTestHolder.__init__cCs
|�|�Srk�r`rzr.r.r/�__call__1szTestHolder.__call__cCs|jSrkr��r]r.r.r/r|5sz
TestHolder.idcCsdSr0r.r�r.r.r/�countTestCases9szTestHolder.countTestCasescCs"|�|�|�|�|�|�dS)z�
        This test is just a placeholder. Run the test successfully.

        @param result: The C{TestResult} to store the results in.
        @type result: L{twisted.trial.itrial.IReporter}.
        N)�	startTest�
addSuccess�stopTestrzr.r.r/r`=s

zTestHolder.runcCs|jSrkr�r�r.r.r/�shortDescriptionIszTestHolder.shortDescription)rFrarbrcZfailureExceptionr$r�r|r�r`r�r.r.r.r/r!scs0eZdZdZ�fdd�Zdd�Zdd�Z�ZS)ra
    Used to insert arbitrary errors into a test suite run. Provides enough
    methods to look like a C{TestCase}, however, when it is run, it simply adds
    an error to the C{TestResult}. The most common use-case is for when a
    module fails to import.
    cs tt|��|�t�|�|_dS)a+
        @param description: A string used by C{TestResult}s to identify this
        error. Generally, this is the name of a module that failed to import.

        @param error: The error to be added to the result. Can be an `exc_info`
        tuple or a L{twisted.python.failure.Failure}.
        N)rdrr$rZexcInfoOrFailureToExcInforg)r]r�rgrhr.r/r$VszErrorHolder.__init__cCsd|j|jdfS)Nz%<ErrorHolder description=%r error=%r>�)r�rgr�r.r.r/�__repr__bs�zErrorHolder.__repr__cCs&|�|�|�||j�|�|�dS)z�
        Run the test, reporting the error.

        @param result: The C{TestResult} to store the results in.
        @type result: L{twisted.trial.itrial.IReporter}.
        N)r�rfrgr�rzr.r.r/r`gs
zErrorHolder.run)rFrarbrcr$r�r`rjr.r.rhr/rNsc@s�eZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
e
Zdd�ZeZ
dd�Zdd�Zdd�Zd$dd�Zdd�Zd%dd�Zd&dd�ZeZd'd d!�Zd"d#�ZdS)(r	a4
    I find tests inside function, modules, files -- whatever -- then return
    them wrapped inside a Test (either a L{TestSuite} or a L{TestCase}).

    @ivar methodPrefix: A string prefix. C{TestLoader} will assume that all the
    methods in a class that begin with C{methodPrefix} are test cases.

    @ivar modulePrefix: A string prefix. Every module in a package that begins
    with C{modulePrefix} is considered a module full of tests.

    @ivar forceGarbageCollection: A flag applied to each C{TestCase} loaded.
    See L{unittest.TestCase} for more information.

    @ivar sorter: A key function used to sort C{TestCase}s, test classes,
    modules and packages.

    @ivar suiteFactory: A callable which is passed a list of tests (which
    themselves may be suites of tests). Must return a test suite.
    r_Ztest_cCst|_t|_g|_dSrk)r�suiteFactoryr�sorterZ
_importErrorsr�r.r.r/r$�szTestLoader.__init__cCst||jd�S)zt
        Sort the given things using L{sorter}.

        @param xs: A list of test cases, class or modules.
        )�key)�sortedr�)r]Zxsr.r.r/�sort�szTestLoader.sortcCs4g}t�|�D]\}}t|�r|�|�q|�|�S)z-Given a module, return all Trial test classes)�inspectZ
getmembersrrmr�)r]r-�classesr�valr.r.r/�findTestClasses�s
zTestLoader.findTestClassescCstj�|�rt|�St�|�S)aB
        Return a Python object given a string describing it.

        @param name: a string which may be either a filename or a
        fully-qualified Python name.

        @return: If C{name} is a filename, return the module. If C{name} is a
        fully-qualified Python name, return the object it refers to.
        )r(r)r8rrr?)r]rr.r.r/�
findByName�s
zTestLoader.findByNamecCs�t|tj�std|f��t|d�r,|��St|d�r>|��S|��}|�|�D]}|�	|�
|��qPt|d�st|S|��}|jD]}|�	|�|��q�|�||g�S)a�
        Return a test suite with all the tests from a module.

        Included are TestCase subclasses and doctests listed in the module's
        __doctests__ module. If that's not good for you, put a function named
        either C{testSuite} or C{test_suite} in your module that returns a
        TestSuite, and I'll use the results of that instead.

        If C{testSuite} and C{test_suite} are both present, then I'll use
        C{testSuite}.
        z%r is not a module�	testSuite�
test_suite�__doctests__)
r%r&r'r��hasattrr�r�r�r��addTest�	loadClassr��loadDoctests)r]r-rpZ	testClassZdocSuiteZdocTestr.r.r/�
loadModule�s



zTestLoader.loadModulecsht�t�s$t�tj�s$td�f��t��s:td�f������}����fdd�|D��}��	|�S)zq
        Given a class which contains test cases, return a sorted list of
        C{TestCase} instances.
        �%r is not a class�%r is not a test casecsg|]}����j|��qSr.��	_makeCase�methodPrefix��.0r��klassr]r.r/�
<listcomp>�s�z(TestLoader.loadClass.<locals>.<listcomp>)
r%�typer&�	ClassTyper�rr>�getTestCaseNamesr�r��r]r��namesrnr.r�r/r��s
�zTestLoader.loadClasscCst�||j�S)z�
        Given a class that contains C{TestCase}s, return a list of names of
        methods that probably contain tests.
        )rZprefixedMethodNamesr�)r]r�r.r.r/r��szTestLoader.getTestCaseNamescCs,t|tj�std|f��|�|jt|��S)z~
        Given a method of a C{TestCase} that represents a test, return a
        C{TestCase} instance for that test.
        z%r not a method)r%r&�
MethodTyper�r�rUrZ�r]rXr.r.r/�
loadMethod�szTestLoader.loadMethodcCs||�Srkr.)r]r�Z
methodNamer.r.r/r��szTestLoader._makeCaseFcCs�t|�std|f��t�|j�}|r0|��}n|��}g}|D]&}|j�d�d�	|j
�r@|�|�q@|��}|�
|�D]B}z|��}	Wnt|jt���}
YnX|�|	�}
|�|
�qz|S)a�
        Load tests from a module object representing a package, and return a
        TestSuite containing those tests.

        Tests are only loaded from modules whose name begins with 'test_'
        (or whatever C{modulePrefix} is set to).

        @param package: a types.ModuleType object (or reasonable facsimile
        obtained by importing) which may contain tests.

        @param recurse: A boolean.  If True, inspect modules within packages
        within the given package (and so on), otherwise, only inspect modules
        in the package itself.

        @raise: TypeError if 'package' is not a package.

        @return: a TestSuite created with my suiteFactory, containing all the
        tests.
        z%r is not a package�.rH)r
r�rZ	getModulerFZwalkModulesZiterModulesrrK�
startswith�modulePrefixrmr�r��loadrr�Failurer�r�)r]�package�recurseZpkgobjZ	discoveryZ
discoveredZdiscorpZmodinfor-Z
thingToAddr.r.r/�loadPackage�s&

zTestLoader.loadPackagecCsxt|t�r4zt�|�}Wnt|t���YSXt�|�sLt	�
d�dSi}tjdkrjdd�}||d<t
j|f|�S)z�
        Return a suite of tests for all the doctests defined in C{module}.

        @param module: A module object or a module name.
        z&trial only supports doctesting modulesN)��cSs t|d|j�|_|j��|_dS)z�
                Save C{test.globs} and replace it with a copy so that if
                necessary, the original will be available for the next test
                run.
                �
_savedGlobalsN)rCZglobsr��copy)r_r.r.r/�saveGlobals,sz,TestLoader.loadDoctests.<locals>.saveGlobalsZsetUp)r%�strrr?rrr�r�Zismodule�warnings�warnrE�version_info�doctestZDocTestSuite)r]r-Z	extraArgsr�r.r.r/r�s



zTestLoader.loadDoctestsNcCs|t|tj�r*t|�r |�||�S|�|�St|tj�r@|�|�St|t�rT|�|�St|tj	�rj|�
|�Std|f��dS)a
        Given a Python object, return whatever tests that are in it. Whatever
        'in' might mean.

        @param thing: A Python object. A module, method, class or package.
        @param recurse: Whether or not to look in subpackages of packages.
        Defaults to False.

        @param parent: For compatibility with the Python 3 loader, does
            nothing.
        @param qualname: For compatibility with the Python 3 loader, does
            nothing.

        @return: A C{TestCase} or C{TestSuite}.
        z#No loader for %r. Unrecognized typeN)r%r&r'r
r�r�r�r�r�r�r�r�)r]r}r��parent�qualNamer.r.r/�loadAnything7s




zTestLoader.loadAnythingcCs6z|�|�}Wnt|t���YSX|�||�S)a`
        Given a string representing a Python object, return whatever tests
        are in that object.

        If C{name} is somehow inaccessible (e.g. the module can't be imported,
        there is no Python object with that name etc) then return an
        L{ErrorHolder}.

        @param name: The fully-qualified name of a Python object.
        )r�rrr�r�)r]rr�r}r.r.r/�
loadByNameSs
zTestLoader.loadByNamec
svg}g}|D]:}z|���|��Wq|�t|t����YqXq��fdd���|�D�}|�|���|�S)a
        Construct a TestSuite containing all the tests found in 'names', where
        names is a list of fully qualified python names and/or filenames. The
        suite returned will have no duplicate tests, even if the same object
        is named twice.
        csg|]}��|���qSr.)r�)r�r}�r�r]r.r/r�ts�z*TestLoader.loadByNames.<locals>.<listcomp>)rmr�rrr��_uniqueTests�extendr�)r]r�r��things�errorsrZsuitesr.r�r/�loadByNamesfs�
zTestLoader.loadByNamesccsNt�}|D]>}t|tj�r&||jf}n|f}||kr
|dV|�|�q
dS)�

        Gather unique suite objects from loaded things. This will guarantee
        uniqueness of inherited methods on TestCases which would otherwise hash
        to same value and collapse to one test unexpectedly if using simpler
        means: e.g. set().
        rN)�setr%r&r�rU�add)r]r��seenr}r.r.r/r�zs
zTestLoader._uniqueTests)F)FNN)F)F)rFrarbrcr�r�r$r�r�r�r��loadTestsFromModuler��loadTestsFromTestCaser�r�r�r�r�r�r�ZloadTestsFromNamer�r�r.r.r.r/r	ts*
	
*


c@sZeZdZdZddd�Zddd�Zddd	�Zdd
d�Zddd
�Zdd�Z	dd�Z
dd�ZdS)�
Py3TestLoaderz�
    A test loader finds tests from the functions, modules, and files that is
    asked to and loads them into a L{TestSuite} or L{TestCase}.

    See L{TestLoader} for further details.
    FcCs\ddlm}t�|�}z|||���}|j||d�WStk
rVtd�|���YnXdS)a1
        Load a file, and then the tests in that file.

        @param fileName: The file name to load.
        @param recurse: A boolean. If True, inspect modules within packages
            within the given package (and so on), otherwise, only inspect
            modules in the package itself.
        r)�SourceFileLoader�r�z{} is not a Python file.N)	�importlib.machineryr�rr@�load_moduler��OSErrorr>�format)r]ZfileNamer�r�rr-r.r.r/�loadFile�s	
zPy3TestLoader.loadFilec
	Cs8tj|krFt�|�}zt|�WqJtk
rB|j||d�YSXn|}d}}}t|�D]N\}}zt�|�}|}Wq�Wq^tk
r�|dkr�t�	d�
|���Yq^Xq^|dkr�t�|�}|�d�t
d�|j��dd�}z|D]}	|t||	�}}q�Wn$tk
�r$td�
|���YnX|j||||d�S)	a�
        Find and load tests, given C{name}.

        This partially duplicates the logic in C{unittest.loader.TestLoader}.

        @param name: The qualified name of the thing to load.
        @param recurse: A boolean. If True, inspect modules within packages
            within the given package (and so on), otherwise, only inspect
            modules in the package itself.
        r�N�zThe module {} does not exist.r�r�z{} does not exist.)r�r�r�)r(�seprr@�
__import__�ImportErrorr��_qualNameWalkerZnamedModuleZModuleNotFoundr�r?rK�lenrFrCrAr�)
r]�_namer�rr�r�Z	remainingZ
searchNameZ
remainingName�partr.r.r/r��s6




"
�zPy3TestLoader.findByNameNcCs�t|tj�r,t|�r"|j||d�S|�|�St|t�rLt|tj	�rL|�
|�St|tj�r�t|t�r�t|tj	�r�|d}||�}t||j
�j|ks�t�|St|t�r�|Std|f��dS)a�
        Load absolutely anything (as long as that anything is a module,
        package, class, or method (with associated parent class and qualname).

        @param obj: The object to load.
        @param recurse: A boolean. If True, inspect modules within packages
            within the given package (and so on), otherwise, only inspect
            modules in the package itself.
        @param parent: If C{obj} is a method, this is the parent class of the
            method. C{qualName} is also required.
        @param qualName: If C{obj} is a method, this a list containing is the
            qualified name of the method. C{parent} is also required.
        r�rHz$don't know how to make test from: %sN)r%r&r'r
r�r�r�r~rrxr��FunctionTyperCZ_testMethodName�__func__�AssertionErrorrr�)r]r�r�r�r�r�instr.r.r/r��s$

�
�
zPy3TestLoader.loadAnythingc	Cs@z|�|j||d�g�WS|�t|t���g�YSXdS)a*
        Load some tests by name.

        @param name: The qualified name for the test to load.
        @param recurse: A boolean. If True, inspect modules within packages
            within the given package (and so on), otherwise, only inspect
            modules in the package itself.
        r�N)r�r�rrr�)r]rr�r.r.r/r�s	zPy3TestLoader.loadByNamec
Csfg}g}|D]>}z|�|j||d��Wq|�t|t����YqXq|�|�|�|�|��S)a+
        Load some tests by a list of names.

        @param names: A L{list} of qualified names.
        @param recurse: A boolean. If True, inspect modules within packages
            within the given package (and so on), otherwise, only inspect
            modules in the package itself.
        r�)rmr�rrr�r�r�r�)r]r�r�r�r�rr.r.r/r�)s	
zPy3TestLoader.loadByNamescs\t�t�std�f��t��s.td�f������}����fdd�|D��}��|�S)z�
        Given a class which contains test cases, return a list of L{TestCase}s.

        @param klass: The class to load tests from.
        r�r�csg|]}����j|��qSr.r�r�r�r.r/r�Hs�z+Py3TestLoader.loadClass.<locals>.<listcomp>)r%r�r�rr>r�r�r�r�r.r�r/r�=s

�zPy3TestLoader.loadClasscCstd��dS)NzCan't happen on Py3)�NotImplementedErrorr�r.r.r/r�MszPy3TestLoader.loadMethodccsDt�}|D]4}|j}|D]$}t|�|kr|V|�t|��qq
dS)r�N)r�r[r�r�)r]r�r�Z	testthingZ
testthingsr}r.r.r/r�QszPy3TestLoader._uniqueTests)F)F)FNN)F)F)rFrarbrcr�r�r�r�r�r�r�r�r.r.r.r/r��s

D
-

r�ccsP|gfV|�d�}tdt|��D](}d�|d|��||d�fVq"dS)a3
    Given a Python qualified name, this function yields a 2-tuple of the most
    specific qualified name first, followed by the next-most-specific qualified
    name, and so on, paired with the remainder of the qualified name.

    @param qualName: A Python qualified name.
    @type qualName: L{str}
    r�r�N)rK�ranger�r9)r�Z	qualParts�indexr.r.r/r�bs


r�c@s�eZdZdZdZdZdd�Zdd�ZeZ	dd	�Z
d
dejdd
ddd
dd
dfdd�Z
dd�Zdd�Zdd�Zddd�Zdd�Zd
S)r
z=
    A specialised runner that the trial front end uses.
    �debugzdry-runcCs<|��t��}t�|j�}t�|�\}|_t�	|j
�|Srk)�_tearDownLogFiler(�getcwdrZFilePath�workingDirectoryrZ_unusedTestDirectory�_testDirLock�chdirr))r]Z
currentDir�baseZtestdirr.r.r/�
_setUpTestdir�szTrialRunner._setUpTestdircCst�|�|j��dSrk)r(r�r�Zunlock)r]�oldDirr.r.r/�_tearDownTestdir�s
zTrialRunner._tearDownTestdircCs8|�|j|j|j|j�}|jr&t|�}|jr4t|�}|Srk)	�reporterFactory�stream�tbformat�rterrors�_log�
_exitFirstr�uncleanWarningsr)r]Zreporterr.r.r/�_makeResult�s�zTrialRunner._makeResultNztest.logF�defaultc

Csp||_||_||_||_||_||_||_d|_|	p6d|_d|_	d|_
|
|_||_||_
|rlt�|jd�|_dS)NZ_trial_tempzprofile.data)r��logfile�moder�r�r�r�Z_resultr��_logFileObserver�_logFileObject�_forceGarbageCollection�debuggerr�rZprofiledr`)
r]r�r�r�r�ZprofileZtracebackFormatZrealTimeErrorsr�r�rorZ	exitFirstr.r.r/r$�s 
zTrialRunner.__init__cCs<|jdk	rt�|jj�d|_|jdk	r8|j��d|_dSrk)rrZremoveObserver�emitr�closer�r.r.r/r��s


zTrialRunner._tearDownLogFilecCsL|��|jdkrtj}nt|jd�}||_t�|�|_t�	|jj
d�dS)N�-�ar)r�r�rE�stdoutrQrrZFileLogObserverrZstartLoggingWithObserverr)r]ZlogFiler.r.r/�
_setUpLogFile�s
zTrialRunner._setUpLogFilecCst�|t�}|�||j�S)zC
        Run the test or suite and return a result object.
        )rrlr�_runWithoutDecorationr)r]r_r.r.r/r`�szTrialRunner.runc		s4����t|g|��t��}�j�jkrVt��D]"}��|���|���|�q0n\�j�j	krt���fdd�}n��fdd�}��
�}z��
�|�W5�����|�Xt��}t�dd�}|dk�r(tjdt��j�tdd�������j���d	�j||���d
����n����S)zR
        Private helper that runs the given test but doesn't decorate it.
        cs�j��j��Srk)rZruncallr`r.�r^r]rpr.r/ru�rvz3TrialRunner._runWithoutDecoration.<locals>.<lambda>cs
����Srkr�r.)r^rpr.r/ru�rv�doneNzR%s should implement done() but doesn't. Falling back to printErrors() and friends.�)�category�
stacklevelzRan %d tests in %.3fs�
)r�r�timer��DRY_RUNr!r�r�r��DEBUGr�r�r�r	rCr�r�rr{ri�DeprecationWarningZprintErrorsZwritelnZ	separator�testsRun�writeZprintSummaryr)	r]r_roZ	startTimeZsingler`r�ZendTimerr.rr/r
�sH




��
�

z!TrialRunner._runWithoutDecorationcCsXd}|d7}|j�d|f�|dkr2|�|�}n
|�|�}|jdkrHqT|��sqTq|S)z8
        Repeatedly run C{test} until it fails.
        rr�z
Test Pass %d
)r�rr`r
rZ
wasSuccessful)r]r_�countr^r.r.r/�runUntilFailures

zTrialRunner.runUntilFailure)F)rFrarbrcrrr�r�rr�r�rErr$r�r	r`r
rr.r.r.r/r
~s0	
�

/)N)>rcZ
__future__rr�__all__r�r�r(rErr&r�Ztwisted.pythonrrrrrZtwisted.python.compatrrrwrZ
twisted.trialrrZtwisted.trial.itrialrZtwisted.trial.reporterrrZtwisted.trial._asyncrunnerr r!Ztwisted.trial._synctestr"Ztwisted.trial.unittestrZzope.interfacer#r�rr
rrrrBrJrZrrrrrrrVrrr	r�r�r
r.r.r.r/�<module>sz�
#

&,&U