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.

test.support.EnvironmentVarGuard.unset()

EnvironmentVarGuard.unset(envvar) Temporarily unset the environment variable envvar.

test.support.EnvironmentVarGuard.set()

EnvironmentVarGuard.set(envvar, value) Temporarily set the environment variable envvar to the value of value.

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

test.support.check_warnings(*filters, quiet=True) A convenience wrapper for warnings.catch_warnings() that makes it easier to test that a warning was correctly raised. It is approximately equivalent to calling warnings.catch_warnings(record=True) with warnings.simplefilter() set to always and with the option to automatically validate the results that are recorded. check_warnings accepts 2-tuples of the form ("message regexp", WarningCategory) as positional arguments. If one or more filters a

test.support.change_cwd()

test.support.change_cwd(path, quiet=False) A context manager that temporarily changes the current working directory to path and yields the directory. If quiet is False, the context manager raises an exception on error. Otherwise, it issues only a warning and keeps the current working directory the same.

test.support.captured_stdout()

test.support.captured_stdout() test.support.captured_stderr() A context managers that temporarily replaces the named stream with io.StringIO object. Example use with output streams: with captured_stdout() as stdout, captured_stderr() as stderr: print("hello") print("error", file=sys.stderr) assert stdout.getvalue() == "hello\n" assert stderr.getvalue() == "error\n" Example use with input stream: with captured_stdin() as stdin: stdin.write('hello\n') stdin.seek(0) # call t

test.support.captured_stdin()

test.support.captured_stdin() test.support.captured_stdout() test.support.captured_stderr() A context managers that temporarily replaces the named stream with io.StringIO object. Example use with output streams: with captured_stdout() as stdout, captured_stderr() as stderr: print("hello") print("error", file=sys.stderr) assert stdout.getvalue() == "hello\n" assert stderr.getvalue() == "error\n" Example use with input stream: with captured_stdin() as stdin: stdin.write('hello\n')

test.support.captured_stderr()

test.support.captured_stderr() A context managers that temporarily replaces the named stream with io.StringIO object. Example use with output streams: with captured_stdout() as stdout, captured_stderr() as stderr: print("hello") print("error", file=sys.stderr) assert stdout.getvalue() == "hello\n" assert stderr.getvalue() == "error\n" Example use with input stream: with captured_stdin() as stdin: stdin.write('hello\n') stdin.seek(0) # call test code that consumes from sy

test.support.can_symlink()

test.support.can_symlink() Return True if the OS supports symbolic links, False otherwise.