Back to module index
Go to module by name
unittest
unittest.result
Test result object
Classes
TestResult
Holder for test result information.
Test results are automatically managed by the TestCase and TestSuite
classes, and do not need to be explicitly manipulated by writers of tests.
Each instance holds the total number of tests run, and collections of
failures and errors that occurred among those test runs. The collections
contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
formatted traceback of the error that occurred.
addError(self, test, err)
Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info().
addExpectedFailure(self, test, err)
Called when an expected failure/error occurred.
addFailure(self, test, err)
Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info().
addSkip(self, test, reason)
Called when a test is skipped.
addSubTest(self, test, subtest, err)
Called at the end of a subtest.
'err' is None if the subtest ended successfully, otherwise it's a
tuple of values as returned by sys.exc_info().
addSuccess(self, test)
Called when a test has completed successfully
addUnexpectedSuccess(self, test)
Called when a test was expected to fail, but succeed.
printErrors(self)
Called by TestRunner after test run
startTest(self, test)
Called when the given test is about to be run
startTestRun(self)
Called once before any tests are executed.
See startTest for a method called before each test.
stop(self)
Indicates that the tests should be aborted.
stopTest(self, test)
Called when the given test has been run
stopTestRun(self)
Called once after all tests are executed.
See stopTest for a method called after each test.
wasSuccessful(self)
Tells whether or not this result was a success.
Functions
failfast
failfast(method)
wraps
wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__'), updated=('__dict__',))
Decorator factory to apply update_wrapper() to a wrapper function
Returns a decorator that invokes update_wrapper() with the decorated
function as the wrapper argument and the arguments to wraps() as the
remaining arguments. Default arguments are as for update_wrapper().
This is a convenience function to simplify applying partial() to
update_wrapper().
Other members
STDERR_LINE = '\nStderr:\n%s'
STDOUT_LINE = '\nStdout:\n%s'
Modules
io
sys
traceback
util