doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
run(test)
Run test and return the result. | python.library.test#test.support.BasicTestRunner.run |
@test.support.bigaddrspacetest(f)
Decorator for tests that fill the address space. f is the function to wrap. | python.library.test#test.support.bigaddrspacetest |
@test.support.bigmemtest(size, memuse, dry_run=True)
Decorator for bigmem tests. size is a requested size for the test (in arbitrary, test-interpreted units.) memuse is the number of bytes per unit for the test, or a good estimate of it. For example, a test that needs two byte buffers, of 4 GiB each, could be decorated with @bigmemtest(size=_4G, memuse=2). The size argument is normally passed to the decorated test method as an extra argument. If dry_run is True, the value passed to the test method may be less than the requested value. If dry_run is False, it means the test doesn’t support dummy runs when -M is not specified. | python.library.test#test.support.bigmemtest |
class test.support.bytecode_helper.BytecodeTestCase(unittest.TestCase)
This class has custom assertion methods for inspecting bytecode. | python.library.test#test.support.bytecode_helper.BytecodeTestCase |
BytecodeTestCase.assertInBytecode(x, opname, argval=_UNSPECIFIED)
Return instr if opname is found, otherwise throws AssertionError. | python.library.test#test.support.bytecode_helper.BytecodeTestCase.assertInBytecode |
BytecodeTestCase.assertNotInBytecode(x, opname, argval=_UNSPECIFIED)
Throws AssertionError if opname is found. | python.library.test#test.support.bytecode_helper.BytecodeTestCase.assertNotInBytecode |
BytecodeTestCase.get_disassembly_as_string(co)
Return the disassembly of co as string. | python.library.test#test.support.bytecode_helper.BytecodeTestCase.get_disassembly_as_string |
test.support.calcobjsize(fmt)
Return struct.calcsize() for nP{fmt}0n or, if gettotalrefcount exists, 2PnP{fmt}0P. | python.library.test#test.support.calcobjsize |
test.support.calcvobjsize(fmt)
Return struct.calcsize() for nPn{fmt}0n or, if gettotalrefcount exists, 2PnPn{fmt}0P. | python.library.test#test.support.calcvobjsize |
test.support.can_symlink()
Return True if the OS supports symbolic links, False otherwise. | python.library.test#test.support.can_symlink |
test.support.can_xattr()
Return True if the OS supports xattr, False otherwise. | python.library.test#test.support.can_xattr |
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')
stdin.seek(0)
# call test code that consumes from sys.stdin
captured = input()
self.assertEqual(captured, "hello") | python.library.test#test.support.captured_stderr |
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')
stdin.seek(0)
# call test code that consumes from sys.stdin
captured = input()
self.assertEqual(captured, "hello") | python.library.test#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')
stdin.seek(0)
# call test code that consumes from sys.stdin
captured = input()
self.assertEqual(captured, "hello") | python.library.test#test.support.captured_stdout |
test.support.catch_threading_exception()
Context manager catching threading.Thread exception using threading.excepthook(). Attributes set when an exception is catched: exc_type exc_value exc_traceback thread See threading.excepthook() documentation. These attributes are deleted at the context manager exit. Usage: with support.catch_threading_exception() as cm:
# code spawning a thread which raises an exception
...
# check the thread exception, use cm attributes:
# exc_type, exc_value, exc_traceback, thread
...
# exc_type, exc_value, exc_traceback, thread attributes of cm no longer
# exists at this point
# (to avoid reference cycles)
New in version 3.8. | python.library.test#test.support.catch_threading_exception |
test.support.catch_unraisable_exception()
Context manager catching unraisable exception using sys.unraisablehook(). Storing the exception value (cm.unraisable.exc_value) creates a reference cycle. The reference cycle is broken explicitly when the context manager exits. Storing the object (cm.unraisable.object) can resurrect it if it is set to an object which is being finalized. Exiting the context manager clears the stored object. Usage: with support.catch_unraisable_exception() as cm:
# code creating an "unraisable exception"
...
# check the unraisable exception: use cm.unraisable
...
# cm.unraisable attribute no longer exists at this point
# (to break a reference cycle)
New in version 3.8. | python.library.test#test.support.catch_unraisable_exception |
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. | python.library.test#test.support.change_cwd |
test.support.checksizeof(test, o, size)
For testcase test, assert that the sys.getsizeof for o plus the GC header size equals size. | python.library.test#test.support.checksizeof |
test.support.check_free_after_iterating(test, iter, cls, args=())
Assert that iter is deallocated after iterating. | python.library.test#test.support.check_free_after_iterating |
test.support.check_impl_detail(**guards)
Use this check to guard CPython’s implementation-specific tests or to run them only on the implementations guarded by the arguments: check_impl_detail() # Only on CPython (default).
check_impl_detail(jython=True) # Only on Jython.
check_impl_detail(cpython=False) # Everywhere except CPython. | python.library.test#test.support.check_impl_detail |
test.support.check_no_resource_warning(testcase)
Context manager to check that no ResourceWarning was raised. You must remove the object which may emit ResourceWarning before the end of the context manager. | python.library.test#test.support.check_no_resource_warning |
test.support.check_syntax_error(testcase, statement, errtext='', *, lineno=None, offset=None)
Test for syntax errors in statement by attempting to compile statement. testcase is the unittest instance for the test. errtext is the regular expression which should match the string representation of the raised SyntaxError. If lineno is not None, compares to the line of the exception. If offset is not None, compares to the offset of the exception. | python.library.test#test.support.check_syntax_error |
test.support.check_syntax_warning(testcase, statement, errtext='', *, lineno=1, offset=None)
Test for syntax warning in statement by attempting to compile statement. Test also that the SyntaxWarning is emitted only once, and that it will be converted to a SyntaxError when turned into error. testcase is the unittest instance for the test. errtext is the regular expression which should match the string representation of the emitted SyntaxWarning and raised SyntaxError. If lineno is not None, compares to the line of the warning and exception. If offset is not None, compares to the offset of the exception. New in version 3.8. | python.library.test#test.support.check_syntax_warning |
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 are provided, or if the optional keyword argument quiet is False, it checks to make sure the warnings are as expected: each specified filter must match at least one of the warnings raised by the enclosed code or the test fails, and if any warnings are raised that do not match any of the specified filters the test fails. To disable the first of these checks, set quiet to True. If no arguments are specified, it defaults to: check_warnings(("", Warning), quiet=True)
In this case all warnings are caught and no errors are raised. On entry to the context manager, a WarningRecorder instance is returned. The underlying warnings list from catch_warnings() is available via the recorder object’s warnings attribute. As a convenience, the attributes of the object representing the most recent warning can also be accessed directly through the recorder object (see example below). If no warning has been raised, then any of the attributes that would otherwise be expected on an object representing a warning will return None. The recorder object also has a reset() method, which clears the warnings list. The context manager is designed to be used like this: with check_warnings(("assertion is always true", SyntaxWarning),
("", UserWarning)):
exec('assert(False, "Hey!")')
warnings.warn(UserWarning("Hide me!"))
In this case if either warning was not raised, or some other warning was raised, check_warnings() would raise an error. When a test needs to look more deeply into the warnings, rather than just checking whether or not they occurred, code like this can be used: with check_warnings(quiet=True) as w:
warnings.warn("foo")
assert str(w.args[0]) == "foo"
warnings.warn("bar")
assert str(w.args[0]) == "bar"
assert str(w.warnings[0].args[0]) == "foo"
assert str(w.warnings[1].args[0]) == "bar"
w.reset()
assert len(w.warnings) == 0
Here all warnings will be caught, and the test code tests the captured warnings directly. Changed in version 3.2: New optional arguments filters and quiet. | python.library.test#test.support.check_warnings |
test.support.check__all__(test_case, module, name_of_module=None, extra=(), blacklist=())
Assert that the __all__ variable of module contains all public names. The module’s public names (its API) are detected automatically based on whether they match the public name convention and were defined in module. The name_of_module argument can specify (as a string or tuple thereof) what module(s) an API could be defined in order to be detected as a public API. One case for this is when module imports part of its public API from other modules, possibly a C backend (like csv and its _csv). The extra argument can be a set of names that wouldn’t otherwise be automatically detected as “public”, like objects without a proper __module__ attribute. If provided, it will be added to the automatically detected ones. The blacklist argument can be a set of names that must not be treated as part of the public API even though their names indicate otherwise. Example use: import bar
import foo
import unittest
from test import support
class MiscTestCase(unittest.TestCase):
def test__all__(self):
support.check__all__(self, foo)
class OtherTestCase(unittest.TestCase):
def test__all__(self):
extra = {'BAR_CONST', 'FOO_CONST'}
blacklist = {'baz'} # Undocumented name.
# bar imports part of its API from _bar.
support.check__all__(self, bar, ('bar', '_bar'),
extra=extra, blacklist=blacklist)
New in version 3.6. | python.library.test#test.support.check__all__ |
class test.support.CleanImport(*module_names)
A context manager to force import to return a new module reference. This is useful for testing module-level behaviors, such as the emission of a DeprecationWarning on import. Example usage: with CleanImport('foo'):
importlib.import_module('foo') # New reference. | python.library.test#test.support.CleanImport |
@test.support.cpython_only(test)
Decorator for tests only applicable to CPython. | python.library.test#test.support.cpython_only |
test.support.create_empty_file(filename)
Create an empty file with filename. If it already exists, truncate it. | python.library.test#test.support.create_empty_file |
test.support.detect_api_mismatch(ref_api, other_api, *, ignore=())
Returns the set of attributes, functions or methods of ref_api not found on other_api, except for a defined list of items to be ignored in this check specified in ignore. By default this skips private attributes beginning with ‘_’ but includes all magic methods, i.e. those starting and ending in ‘__’. New in version 3.5. | python.library.test#test.support.detect_api_mismatch |
class test.support.DirsOnSysPath(*paths)
A context manager to temporarily add directories to sys.path. This makes a copy of sys.path, appends any directories given as positional arguments, then reverts sys.path to the copied settings when the context ends. Note that all sys.path modifications in the body of the context manager, including replacement of the object, will be reverted at the end of the block. | python.library.test#test.support.DirsOnSysPath |
test.support.disable_faulthandler()
A context manager that replaces sys.stderr with sys.__stderr__. | python.library.test#test.support.disable_faulthandler |
test.support.disable_gc()
A context manager that disables the garbage collector upon entry and reenables it upon exit. | python.library.test#test.support.disable_gc |
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. | python.library.test#test.support.EnvironmentVarGuard |
EnvironmentVarGuard.set(envvar, value)
Temporarily set the environment variable envvar to the value of value. | python.library.test#test.support.EnvironmentVarGuard.set |
EnvironmentVarGuard.unset(envvar)
Temporarily unset the environment variable envvar. | python.library.test#test.support.EnvironmentVarGuard.unset |
class test.support.FakePath(path)
Simple path-like object. It implements the __fspath__() method which just returns the path argument. If path is an exception, it will be raised in __fspath__(). | python.library.test#test.support.FakePath |
test.support.fd_count()
Count the number of open file descriptors. | python.library.test#test.support.fd_count |
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. | python.library.test#test.support.findfile |
test.support.forget(module_name)
Remove the module named module_name from sys.modules and delete any byte-compiled files of the module. | python.library.test#test.support.forget |
test.support.fs_is_case_insensitive(directory)
Return True if the file system for directory is case-insensitive. | python.library.test#test.support.fs_is_case_insensitive |
test.support.FS_NONASCII
A non-ASCII character encodable by os.fsencode(). | python.library.test#test.support.FS_NONASCII |
test.support.gc_collect()
Force as many objects as possible to be collected. This is needed because timely deallocation is not guaranteed by the garbage collector. This means that __del__ methods may be called later than expected and weakrefs may remain alive for longer than expected. | python.library.test#test.support.gc_collect |
test.support.get_attribute(obj, name)
Get an attribute, raising unittest.SkipTest if AttributeError is raised. | python.library.test#test.support.get_attribute |
test.support.get_original_stdout()
Return the original stdout set by record_original_stdout() or sys.stdout if it’s not set. | python.library.test#test.support.get_original_stdout |
test.support.HAVE_DOCSTRINGS
Check for presence of docstrings. | python.library.test#test.support.HAVE_DOCSTRINGS |
@test.support.impl_detail(msg=None, **guards)
Decorator for invoking check_impl_detail() on guards. If that returns False, then uses msg as the reason for skipping the test. | python.library.test#test.support.impl_detail |
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 in the module cache during the import to ensure that attempts to import them raise ImportError. The named module and any modules named in the fresh and blocked parameters are saved before starting the import and then reinserted into sys.modules when the fresh import is complete. Module and package deprecation messages are suppressed during this import if deprecated is True. This function will raise ImportError if the named module cannot be imported. Example use: # Get copies of the warnings module for testing without affecting the
# version being used by the rest of the test suite. One copy uses the
# C implementation, the other is forced to use the pure Python fallback
# implementation
py_warnings = import_fresh_module('warnings', blocked=['_warnings'])
c_warnings = import_fresh_module('warnings', fresh=['_warnings'])
New in version 3.1. | python.library.test#test.support.import_fresh_module |
test.support.import_module(name, deprecated=False, *, required_on())
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. If a module is required on a platform but optional for others, set required_on to an iterable of platform prefixes which will be compared against sys.platform. New in version 3.1. | python.library.test#test.support.import_module |
test.support.INTERNET_TIMEOUT
Timeout in seconds for network requests going to the Internet. The timeout is short enough to prevent a test to wait for too long if the Internet request is blocked for whatever reason. Usually, a timeout using INTERNET_TIMEOUT should not mark a test as failed, but skip the test instead: see transient_internet(). Its default value is 1 minute. See also LOOPBACK_TIMEOUT. | python.library.test#test.support.INTERNET_TIMEOUT |
test.support.is_android
True if the system is Android. | python.library.test#test.support.is_android |
test.support.is_jython
True if the running interpreter is Jython. | python.library.test#test.support.is_jython |
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. | python.library.test#test.support.is_resource_enabled |
test.support.join_thread(thread, timeout=30.0)
Join a thread within timeout. Raise an AssertionError if thread is still alive after timeout seconds. | python.library.test#test.support.join_thread |
test.support.LARGEST
Object that is greater than anything (except itself). Used to test mixed type comparison. | python.library.test#test.support.LARGEST |
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) | python.library.test#test.support.load_package_tests |
test.support.LONG_TIMEOUT
Timeout in seconds to detect when a test hangs. It is long enough to reduce the risk of test failure on the slowest Python buildbots. It should not be used to mark a test as failed if the test takes “too long”. The timeout value depends on the regrtest --timeout command line option. Its default value is 5 minutes. See also LOOPBACK_TIMEOUT, INTERNET_TIMEOUT and SHORT_TIMEOUT. | python.library.test#test.support.LONG_TIMEOUT |
test.support.LOOPBACK_TIMEOUT
Timeout in seconds for tests using a network server listening on the network local loopback interface like 127.0.0.1. The timeout is long enough to prevent test failure: it takes into account that the client and the server can run in different threads or even different processes. The timeout should be long enough for connect(), recv() and send() methods of socket.socket. Its default value is 5 seconds. See also INTERNET_TIMEOUT. | python.library.test#test.support.LOOPBACK_TIMEOUT |
test.support.make_bad_fd()
Create an invalid file descriptor by opening and closing a temporary file, and returning its descriptor. | python.library.test#test.support.make_bad_fd |
test.support.make_legacy_pyc(source)
Move a PEP 3147/PEP 488 pyc file to its legacy pyc location and return the file system path to the legacy pyc file. The source value is the file system path to the source file. It does not need to exist, however the PEP 3147/488 pyc file must exist. | python.library.test#test.support.make_legacy_pyc |
class test.support.Matcher
matches(self, d, **kwargs)
Try to match a single dict with the supplied arguments.
match_value(self, k, dv, v)
Try to match a single stored value (dv) with a supplied value (v). | python.library.test#test.support.Matcher |
matches(self, d, **kwargs)
Try to match a single dict with the supplied arguments. | python.library.test#test.support.Matcher.matches |
match_value(self, k, dv, v)
Try to match a single stored value (dv) with a supplied value (v). | python.library.test#test.support.Matcher.match_value |
test.support.match_test(test)
Match test to patterns set in set_match_tests(). | python.library.test#test.support.match_test |
test.support.max_memuse
Set by set_memlimit() as the memory limit for big memory tests. Limited by MAX_Py_ssize_t. | python.library.test#test.support.max_memuse |
test.support.MAX_Py_ssize_t
Set to sys.maxsize for big memory tests. | python.library.test#test.support.MAX_Py_ssize_t |
test.support.missing_compiler_executable(cmd_names=[])
Check for the existence of the compiler executables whose names are listed in cmd_names or all the compiler executables when cmd_names is empty and return the first missing executable or None when none is found missing. | python.library.test#test.support.missing_compiler_executable |
test.support.MISSING_C_DOCSTRINGS
Return True if running on CPython, not on Windows, and configuration not set with WITH_DOC_STRINGS. | python.library.test#test.support.MISSING_C_DOCSTRINGS |
test.support.modules_cleanup(oldmodules)
Remove modules except for oldmodules and encodings in order to preserve internal cache. | python.library.test#test.support.modules_cleanup |
test.support.modules_setup()
Return a copy of sys.modules. | python.library.test#test.support.modules_setup |
test.support.NEVER_EQ
Object that is not equal to anything (even to ALWAYS_EQ). Used to test mixed type comparison. | python.library.test#test.support.NEVER_EQ |
@test.support.no_tracing(func)
Decorator to temporarily turn off tracing for the duration of the test. | python.library.test#test.support.no_tracing |
test.support.open_urlresource(url, *args, **kw)
Open url. If open fails, raises TestFailed. | python.library.test#test.support.open_urlresource |
test.support.optim_args_from_interpreter_flags()
Return a list of command line arguments reproducing the current optimization settings in sys.flags. | python.library.test#test.support.optim_args_from_interpreter_flags |
test.support.patch(test_instance, object_to_patch, attr_name, new_value)
Override object_to_patch.attr_name with new_value. Also add cleanup procedure to test_instance to restore object_to_patch for attr_name. The attr_name should be a valid attribute for object_to_patch. | python.library.test#test.support.patch |
test.support.PGO
Set when tests can be skipped when they are not useful for PGO. | python.library.test#test.support.PGO |
test.support.PIPE_MAX_SIZE
A constant that is likely larger than the underlying OS pipe buffer size, to make writes blocking. | python.library.test#test.support.PIPE_MAX_SIZE |
test.support.print_warning(msg)
Print a warning into sys.__stderr__. Format the message as: f"Warning -- {msg}". If msg is made of multiple lines, add "Warning -- " prefix to each line. New in version 3.9. | python.library.test#test.support.print_warning |
test.support.python_is_optimized()
Return True if Python was not built with -O0 or -Og. | python.library.test#test.support.python_is_optimized |
test.support.real_max_memuse
Set by set_memlimit() as the memory limit for big memory tests. Not limited by MAX_Py_ssize_t. | python.library.test#test.support.real_max_memuse |
test.support.reap_children()
Use this at the end of test_main whenever sub-processes are started. This will help ensure that no extra children (zombies) stick around to hog resources and create problems when looking for refleaks. | python.library.test#test.support.reap_children |
@test.support.reap_threads(func)
Decorator to ensure the threads are cleaned up even if the test fails. | python.library.test#test.support.reap_threads |
test.support.record_original_stdout(stdout)
Store the value from stdout. It is meant to hold the stdout at the time the regrtest began. | python.library.test#test.support.record_original_stdout |
@test.support.refcount_test(test)
Decorator for tests which involve reference counting. The decorator does not run the test if it is not run by CPython. Any trace function is unset for the duration of the test to prevent unexpected refcounts caused by the trace function. | python.library.test#test.support.refcount_test |
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. | python.library.test#test.support.requires |
@test.support.requires_bz2
Decorator for skipping tests if bz2 doesn’t exist. | python.library.test#test.support.requires_bz2 |
@test.support.requires_docstrings
Decorator for only running the test if HAVE_DOCSTRINGS. | python.library.test#test.support.requires_docstrings |
@test.support.requires_freebsd_version(*min_version)
Decorator for the minimum version when running test on FreeBSD. If the FreeBSD version is less than the minimum, raise unittest.SkipTest. | python.library.test#test.support.requires_freebsd_version |
@test.support.requires_gzip
Decorator for skipping tests if gzip doesn’t exist. | python.library.test#test.support.requires_gzip |
@test.support.requires_IEEE_754
Decorator for skipping tests on non-IEEE 754 platforms. | python.library.test#test.support.requires_IEEE_754 |
@test.support.requires_linux_version(*min_version)
Decorator for the minimum version when running test on Linux. If the Linux version is less than the minimum, raise unittest.SkipTest. | python.library.test#test.support.requires_linux_version |
@test.support.requires_lzma
Decorator for skipping tests if lzma doesn’t exist. | python.library.test#test.support.requires_lzma |
@test.support.requires_mac_version(*min_version)
Decorator for the minimum version when running test on Mac OS X. If the MAC OS X version is less than the minimum, raise unittest.SkipTest. | python.library.test#test.support.requires_mac_version |
@test.support.requires_resource(resource)
Decorator for skipping tests if resource is not available. | python.library.test#test.support.requires_resource |
@test.support.requires_zlib
Decorator for skipping tests if zlib doesn’t exist. | python.library.test#test.support.requires_zlib |
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. | python.library.test#test.support.ResourceDenied |
test.support.rmdir(filename)
Call os.rmdir() on filename. On Windows platforms, this is wrapped with a wait loop that checks for the existence of the file. | python.library.test#test.support.rmdir |
test.support.rmtree(path)
Call shutil.rmtree() on path or call os.lstat() and os.rmdir() to remove a path and its contents. On Windows platforms, this is wrapped with a wait loop that checks for the existence of the files. | python.library.test#test.support.rmtree |
test.support.run_doctest(module, verbosity=None, optionflags=0)
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. optionflags is passed as optionflags to doctest.testmod(). | python.library.test#test.support.run_doctest |
test.support.run_in_subinterp(code)
Run code in subinterpreter. Raise unittest.SkipTest if tracemalloc is enabled. | python.library.test#test.support.run_in_subinterp |
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 will run all tests defined in the named module. | python.library.test#test.support.run_unittest |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.