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`.`reporter`.`SubunitReporter``

class documentation

`class SubunitReporter: (source)`

Constructor: `SubunitReporter(stream, tbformat, realtime, publisher)`

Implements interfaces: `twisted.trial.itrial.IReporter`

View In Hierarchy

Reports test output via Subunit.

Present Since
10.0

Method | `__init__` | Construct a `SubunitReporter`.
Method | `addError` | Record that `test` failed with an unexpected error `err`.
Method | `addExpectedFailure` | Record an expected failure from a test.
Method | `addFailure` | Record that `test` failed an assertion with the error `err`.
Method | `addSkip` | Record that `test` was skipped for `reason`.
Method | `addSuccess` | Record that `test` was successful.
Method | `addUnexpectedSuccess` | Record an unexpected success.
Method | `done` | Record that the entire test suite run is finished.
Method | `startTest` | Record that `test` has started.
Method | `stop` | Signal that the test runner should stop running tests.
Method | `stopTest` | Record that `test` has completed.
Method | `wasSuccessful` | Has the test run been successful so far?
Class Variable | `testsRun` | The number of tests that seem to have been run according to this reporter.
Property | `shouldStop` | Whether or not the test runner should stop running tests.
Instance Variable | `_subunit` | The subunit protocol client that we are wrapping.
Instance Variable | `_successful` | An internal variable, used to track whether we have received only successful results.

def __init__(self, stream=sys.stdout, tbformat='default', realtime=False, publisher=None): (source)

Construct a `SubunitReporter`.

Parameters
stream | A file-like object representing the stream to print output to. Defaults to stdout.
tbformat | The format for tracebacks. Ignored, since subunit always uses Python's standard format.
realtime | Whether or not to print exceptions in the middle of the test results. Ignored, since subunit always does this.
publisher | The log publisher which will be preserved for reporting events. Ignored, as it's not relevant to subunit.

def addError(self, test, err): (source)
from `twisted.trial.itrial.IReporter`

Record that `test` failed with an unexpected error `err`.

Also marks the run as being unsuccessful, causing `SubunitReporter.wasSuccessful` to return `False`.

def addExpectedFailure(self, test, failure, todo=None): (source)
from `twisted.trial.itrial.IReporter`

Record an expected failure from a test.

Some versions of subunit do not implement this. For those versions, we record a success.

def addFailure(self, test, err): (source)
from `twisted.trial.itrial.IReporter`

Record that `test` failed an assertion with the error `err`.

Also marks the run as being unsuccessful, causing `SubunitReporter.wasSuccessful` to return `False`.

def addSkip(self, test, reason): (source)
from `twisted.trial.itrial.IReporter`

Record that `test` was skipped for `reason`.

Some versions of subunit don't have support for addSkip. In those cases, the skip is reported as a success.

Parameters
test | A unittest-compatible `TestCase`.
reason | The reason for it being skipped. The `str()` of this object will be included in the subunit output stream.

def addSuccess(self, test): (source)
from `twisted.trial.itrial.IReporter`

Record that `test` was successful.

def addUnexpectedSuccess(self, test, todo=None): (source)
from `twisted.trial.itrial.IReporter`

Record an unexpected success.

Since subunit has no way of expressing this concept, we record a success on the subunit stream.

def done(self): (source)
from `twisted.trial.itrial.IReporter`

Record that the entire test suite run is finished.

We do nothing, since a summary clause is irrelevant to the subunit protocol.

def startTest(self, test): (source)
from `twisted.trial.itrial.IReporter`

Record that `test` has started.

def stop(self): (source)

Signal that the test runner should stop running tests.

def stopTest(self, test): (source)
from `twisted.trial.itrial.IReporter`

Record that `test` has completed.

def wasSuccessful(self): (source)
from `twisted.trial.itrial.IReporter`

Has the test run been successful so far?

Returns
`True` if we have received no reports of errors or failures, `False` otherwise.

testsRun = (source)
from `twisted.trial.itrial.IReporter`

The number of tests that seem to have been run according to this reporter.

@property
shouldStop = (source)
from `twisted.trial.itrial.IReporter`

Whether or not the test runner should stop running tests.

_subunit = (source)

The subunit protocol client that we are wrapping.

_successful: `bool` = (source)

An internal variable, used to track whether we have received only successful results.