test.support.ResourceDenied

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

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.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.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.is_jython

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

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.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.forget()

test.support.forget(module_name) Remove the module named module_name from sys.modules and delete any byte-compiled files of the module.

test.support.find_unused_port()

test.support.find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM) Returns an unused port that should be suitable for binding. This is achieved by creating a temporary socket with the same family and type as the sock parameter (default is AF_INET, SOCK_STREAM), and binding it to the specified host address (defaults to 0.0.0.0) with the port set to 0, eliciting an unused ephemeral port from the OS. The temporary socket is then closed and deleted, and the ephemeral port is retur