test.support.WarningsRecorder

class test.support.WarningsRecorder Class used to record warnings for unit tests. See documentation of check_warnings() above for more details.

test.support.TestFailed

exception test.support.TestFailed Exception to be raised when a test fails. This is deprecated in favor of unittest-based tests and unittest.TestCase‘s assertion methods.

test.support.temp_cwd()

test.support.temp_cwd(name='tempcwd', quiet=False) A context manager that temporarily creates a new directory and changes the current working directory (CWD). The context manager creates a temporary directory in the current directory with name name before temporarily changing the current working directory. If name is None, the temporary directory is created using tempfile.mkdtemp(). If quiet is False and it is not possible to create or change the CWD, an error is raised. Otherwise, only a wa

test.support.temp_dir()

test.support.temp_dir(path=None, quiet=False) A context manager that creates a temporary directory at path and yields the directory. If path is None, the temporary directory is created using tempfile.mkdtemp(). If quiet is False, the context manager raises an exception on error. Otherwise, if path is specified and cannot be created, only a warning is issued.

test.support.SuppressCrashReport

class test.support.SuppressCrashReport A context manager used to try to prevent crash dialog popups on tests that are expected to crash a subprocess. On Windows, it disables Windows Error Reporting dialogs using SetErrorMode. On UNIX, resource.setrlimit() is used to set resource.RLIMIT_CORE‘s soft limit to 0 to prevent coredump file creation. On both platforms, the old value is restored by __exit__().

test.support.temp_umask()

test.support.temp_umask(umask) A context manager that temporarily sets the process umask.

test.support.skip_unless_symlink()

@test.support.skip_unless_symlink A decorator for running tests that require support for symbolic links.

test.support.run_with_locale()

@test.support.run_with_locale(catstr, *locales) A decorator for running a function in a different locale, correctly resetting it after it has finished. catstr is the locale category as a string (for example "LC_ALL"). The locales passed will be tried sequentially, and the first valid locale will be used.

test.support.run_doctest()

test.support.run_doctest(module, verbosity=None) Run doctest.testmod() on the given module. Return (failure_count, test_count). If verbosity is None, doctest.testmod() is run with verbosity set to verbose. Otherwise, it is run with verbosity set to None.

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