test.support.run_unittest()

test.support.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. It is also legal to pass strings as parameters; these should be keys in sys.modules. Each associated module will be scanned by unittest.TestLoader.loadTestsFromModule(). This is usually seen in the following test_main() function: def test_main(): support.run_unittest(__name__) This

test.support.is_jython

test.support.is_jython True if the running interpreter is Jython.

test.support.import_fresh_module()

test.support.import_fresh_module(name, fresh=(), blocked=(), deprecated=False) This function imports and returns a fresh copy of the named Python module by removing the named module from sys.modules before doing the import. Note that unlike reload(), the original module is not affected by this operation. fresh is an iterable of additional module names that are also removed from the sys.modules cache before doing the import. blocked is an iterable of module names that are replaced with None i

test.support.make_bad_fd()

test.support.make_bad_fd() Create an invalid file descriptor by opening and closing a temporary file, and returning its descriptor.

test.support.load_package_tests()

test.support.load_package_tests(pkg_dir, loader, standard_tests, pattern) Generic implementation of the unittest load_tests protocol for use in test packages. pkg_dir is the root directory of the package; loader, standard_tests, and pattern are the arguments expected by load_tests. In simple cases, the test package’s __init__.py can be the following: import os from test.support import load_package_tests def load_tests(*args): return load_package_tests(os.path.dirname(__file__), *args)

test.support.requires()

test.support.requires(resource, msg=None) Raise 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.

test.support.import_module()

test.support.import_module(name, deprecated=False) This function imports and returns the named module. Unlike a normal import, this function raises unittest.SkipTest if the module cannot be imported. Module and package deprecation messages are suppressed during this import if deprecated is True. New in version 3.1.

test.support.is_resource_enabled()

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

test.support.EnvironmentVarGuard

class test.support.EnvironmentVarGuard Class used to temporarily set or unset environment variables. Instances can be used as a context manager and have a complete dictionary interface for querying/modifying the underlying os.environ. After exit from the context manager all changes to environment variables done through this instance will be rolled back. Changed in version 3.1: Added dictionary interface.

test.support.findfile()

test.support.findfile(filename, subdir=None) 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. Setting subdir indicates a relative path to use to find the file rather than looking directly in the path directories.