5.5 test.test_support -- Utility functions for tests

The test.test_support module provides support for Python's regression tests.

This module defines the following exceptions:

exception TestFailed
Exception to be raised when a test fails.

exception TestSkipped
Subclass of TestFailed. Raised when a test is skipped. This occurs when a needed resource (such as a network connection) is not available at the time of testing.

exception ResourceDenied
Subclass of TestSkipped. Raised when a resource (such as a network connection) is not available. Raised by the requires() function.

The test.test_support module defines the following constants:

True when verbose output is enabled. Should be checked when more detailed information is desired about a running test. verbose is set by test.regrtest.

True when Unicode support is available.

True if the running interpreter is Jython.

Set to the path that a temporary file may be created at. Any temporary that is created should be closed and unlinked (removed).

The test.test_support module defines the following functions:

forget( module_name)
Removes the module named module_name from sys.modules and deletes any byte-compiled files of the module.

is_resource_enabled( resource)
Returns True if resource is enabled and available. The list of available resources is only set when test.regrtest is executing the tests.

requires( resource[, msg])
Raises ResourceDenied if resource is not available. msg is the argument to ResourceDenied if it is raised. Always returns true if called by a function whose __name__ is '__main__'. Used when tests are executed by test.regrtest.

findfile( filename)
Return the path to the file named filename. If no match is found filename is returned. This does not equal a failure since it could be the path to the file.

run_unittest( *classes)
Execute unittest.TestCase subclasses passed to the function. The function scans the classes for methods starting with the prefix "test_" and executes the tests individually. This is the preferred way to execute tests.

run_suite( suite[, testclass])
Execute the unittest.TestSuite instance suite. The optional argument testclass accepts one of the test classes in the suite so as to print out more detailed information on where the testing suite originated from.
See About this document... for information on suggesting changes.