Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`trial`.`runner``

module documentation
(source)

A miscellany of code used to run Trial tests.

Maintainer: Jonathan Lange

Class | `DestructiveTestSuite` | A test suite which remove the tests once run, to minimize memory usage.
Class | `ErrorHolder` | Used to insert arbitrary errors into a test suite run. Provides enough methods to look like a `TestCase`, however, when it is run, it simply adds an error to the `TestResult`. The most common use-case is for when a module fails to import.
Class | `LoggedSuite` | Any errors logged in this suite will be reported to the `TestResult` object.
Class | `TestHolder` | Placeholder for a `TestCase` inside a reporter. As far as a `TestResult` is concerned, this looks exactly like a unit test.
Class | `TestLoader` | I find tests inside function, modules, files -- whatever -- then return them wrapped inside a Test (either a `TestSuite` or a `TestCase`).
Class | `TrialRunner` | A specialised runner that the trial front end uses.
Class | `TrialSuite` | Suite to wrap around every single test in a `trial` run. Used internally by Trial to set up things necessary for Trial tests to work, regardless of what context they are run in.
Function | `filenameToModule` | Given a filename, do whatever possible to return a module object matching that file.
Function | `isPackage` | Given an object return True if the object looks like a package
Function | `isPackageDirectory` | 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
Function | `isTestCase` | No summary
Function | `name` | No summary
Function | `samefile` | A hacky implementation of `os.path.samefile`. Used by `filenameToModule` when the platform doesn't provide `os.path.samefile`. Do not use this.
Constant | `NOT_IN_TEST` | Undocumented
Class | `_Debugger` | Undocumented
Class | `_Runner` | Undocumented
Function | `_getMethodNameInClass` | Find the attribute name on the method's class which refers to the method.
Function | `_importFromFile` | Undocumented
Function | `_logFile` | A context manager which adds a log observer and then removes it.
Function | `_qualNameWalker` | 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.
Function | `_resolveDirectory` | Undocumented
Function | `_testDirectory` | A context manager which obtains a lock on a trial working directory and enters (`os.chdir`) it and then reverses these things.
Constant | `_P` | Undocumented
Type Alias | `_Loadable` | Undocumented

def filenameToModule(fn): (source)

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.

Parameters
fn | A filename.
Returns
A module object.
Raises
`ValueError` | If `fn` does not exist.

def isPackage(module): (source)

Given an object return True if the object looks like a package

def isPackageDirectory(dirname): (source)

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

def isTestCase(obj: `type`) -> `TypeGuard[Type[pyunit.TestCase]]`: (source)

Returns
`TypeGuard[Type[pyunit.TestCase]]` | `True` if `obj` is a class that contains test cases, `False` otherwise. Used to find all the tests in a module.

def name(thing: `_Loadable`) -> `str`: (source)

Parameters
thing:`_Loadable` | an object from modules (instance of PythonModule, PythonAttribute), a TestCase subclass, or an instance of a TestCase.
Returns
`str` | Undocumented

def samefile(filename1, filename2): (source)

A hacky implementation of `os.path.samefile`. Used by `filenameToModule` when the platform doesn't provide `os.path.samefile`. Do not use this.

NOT_IN_TEST: `str` = (source)

Undocumented

Value

    '<not in test>'

def _getMethodNameInClass(method): (source)

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

def _importFromFile(fn, *, moduleName): (source)

Undocumented

@contextmanager
def _logFile(logfile: `str`) -> `Generator[None, None, None]`: (source)

A context manager which adds a log observer and then removes it.

Parameters
logfile:`str` | `"-"` f or stdout logging, otherwise the path to a log file to which to write.
Returns
`Generator[None, None, None]` | Undocumented

def _qualNameWalker(qualName): (source)

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.

Parameters
qualName:`str` | A Python qualified name.

def _resolveDirectory(fn): (source)

Undocumented

@contextmanager
def _testDirectory(workingDirectory: `str`) -> `Generator[None, None, None]`: (source)

A context manager which obtains a lock on a trial working directory and enters (`os.chdir`) it and then reverses these things.

Parameters
workingDirectory:`str` | A pattern for the basename of the working directory to acquire.
Returns
`Generator[None, None, None]` | Undocumented

_P = (source)

Undocumented

Value

    ParamSpec('_P')

_Loadable: `TypeAlias` = (source)

Undocumented

Value

    Union[modules.PythonAttribute,
          modules.PythonModule,
          pyunit.TestCase,
          Type[pyunit.TestCase]]