doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
@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. | python.library.test#test.support.run_with_locale |
@test.support.run_with_tz(tz)
A decorator for running a function in a specific timezone, correctly resetting it after it has finished. | python.library.test#test.support.run_with_tz |
test.support.SAVEDCWD
Set to os.getcwd(). | python.library.test#test.support.SAVEDCWD |
class test.support.SaveSignals
Class to save and restore signal handlers registered by the Python signal handler. | python.library.test#test.support.SaveSignals |
test.support.script_helper.assert_python_failure(*args, **env_vars)
Assert that running the interpreter with args and optional environment variables env_vars fails (rc != 0) and return a (return code,
stdout, stderr) tuple. See assert_python_ok() for more options. Changed in version 3.9: The function no longer strip... | python.library.test#test.support.script_helper.assert_python_failure |
test.support.script_helper.assert_python_ok(*args, **env_vars)
Assert that running the interpreter with args and optional environment variables env_vars succeeds (rc == 0) and return a (return code,
stdout, stderr) tuple. If the __cleanenv keyword is set, env_vars is used as a fresh environment. Python is started in ... | python.library.test#test.support.script_helper.assert_python_ok |
test.support.script_helper.interpreter_requires_environment()
Return True if sys.executable interpreter requires environment variables in order to be able to run at all. This is designed to be used with @unittest.skipIf() to annotate tests that need to use an assert_python*() function to launch an isolated mode (-I) ... | python.library.test#test.support.script_helper.interpreter_requires_environment |
test.support.script_helper.kill_python(p)
Run the given subprocess.Popen process until completion and return stdout. | python.library.test#test.support.script_helper.kill_python |
test.support.script_helper.make_pkg(pkg_dir, init_source='')
Create a directory named pkg_dir containing an __init__ file with init_source as its contents. | python.library.test#test.support.script_helper.make_pkg |
test.support.script_helper.make_script(script_dir, script_basename, source, omit_suffix=False)
Create script containing source in path script_dir and script_basename. If omit_suffix is False, append .py to the name. Return the full script path. | python.library.test#test.support.script_helper.make_script |
test.support.script_helper.make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename, source, depth=1, compiled=False)
Create a zip package directory with a path of zip_dir and zip_basename containing an empty __init__ file and a file script_basename containing the source. If compiled is True, both source files w... | python.library.test#test.support.script_helper.make_zip_pkg |
test.support.script_helper.make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None)
Create zip file at zip_dir and zip_basename with extension zip which contains the files in script_name. name_in_zip is the archive name. Return a tuple containing (full path, full path of archive name). | python.library.test#test.support.script_helper.make_zip_script |
test.support.script_helper.run_python_until_end(*args, **env_vars)
Set up the environment based on env_vars for running the interpreter in a subprocess. The values can include __isolated, __cleanenv, __cwd, and TERM. Changed in version 3.9: The function no longer strips whitespaces from stderr. | python.library.test#test.support.script_helper.run_python_until_end |
test.support.script_helper.spawn_python(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw)
Run a Python subprocess with the given arguments. kw is extra keyword args to pass to subprocess.Popen(). Returns a subprocess.Popen object. | python.library.test#test.support.script_helper.spawn_python |
test.support.setswitchinterval(interval)
Set the sys.setswitchinterval() to the given interval. Defines a minimum interval for Android systems to prevent the system from hanging. | python.library.test#test.support.setswitchinterval |
test.support.set_match_tests(patterns)
Define match test with regular expression patterns. | python.library.test#test.support.set_match_tests |
test.support.set_memlimit(limit)
Set the values for max_memuse and real_max_memuse for big memory tests. | python.library.test#test.support.set_memlimit |
test.support.SHORT_TIMEOUT
Timeout in seconds to mark a test as failed if the test takes “too long”. The timeout value depends on the regrtest --timeout command line option. If a test using SHORT_TIMEOUT starts to fail randomly on slow buildbots, use LONG_TIMEOUT instead. Its default value is 30 seconds. | python.library.test#test.support.SHORT_TIMEOUT |
@test.support.skip_unless_symlink
A decorator for running tests that require support for symbolic links. | python.library.test#test.support.skip_unless_symlink |
@test.support.skip_unless_xattr
A decorator for running tests that require support for xattr. | python.library.test#test.support.skip_unless_xattr |
test.support.SMALLEST
Object that is less than anything (except itself). Used to test mixed type comparison. | python.library.test#test.support.SMALLEST |
test.support.socket_helper.bind_port(sock, host=HOST)
Bind the socket to a free port and return the port number. Relies on ephemeral ports in order to ensure we are using an unbound port. This is important as many tests may be running simultaneously, especially in a buildbot environment. This method raises an excepti... | python.library.test#test.support.socket_helper.bind_port |
test.support.socket_helper.bind_unix_socket(sock, addr)
Bind a unix socket, raising unittest.SkipTest if PermissionError is raised. | python.library.test#test.support.socket_helper.bind_unix_socket |
test.support.socket_helper.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 speci... | python.library.test#test.support.socket_helper.find_unused_port |
test.support.socket_helper.IPV6_ENABLED
Set to True if IPv6 is enabled on this host, False otherwise. | python.library.test#test.support.socket_helper.IPV6_ENABLED |
@test.support.socket_helper.skip_unless_bind_unix_socket
A decorator for running tests that require a functional bind() for Unix sockets. | python.library.test#test.support.socket_helper.skip_unless_bind_unix_socket |
test.support.socket_helper.transient_internet(resource_name, *, timeout=30.0, errnos=())
A context manager that raises ResourceDenied when various issues with the internet connection manifest themselves as exceptions. | python.library.test#test.support.socket_helper.transient_internet |
test.support.SOCK_MAX_SIZE
A constant that is likely larger than the underlying OS socket buffer size, to make writes blocking. | python.library.test#test.support.SOCK_MAX_SIZE |
test.support.sortdict(dict)
Return a repr of dict with keys sorted. | python.library.test#test.support.sortdict |
test.support.start_threads(threads, unlock=None)
Context manager to start threads. It attempts to join the threads upon exit. | python.library.test#test.support.start_threads |
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 preve... | python.library.test#test.support.SuppressCrashReport |
test.support.swap_attr(obj, attr, new_val)
Context manager to swap out an attribute with a new object. Usage: with swap_attr(obj, "attr", 5):
...
This will set obj.attr to 5 for the duration of the with block, restoring the old value at the end of the block. If attr doesn’t exist on obj, it will be created and t... | python.library.test#test.support.swap_attr |
test.support.swap_item(obj, attr, new_val)
Context manager to swap out an item with a new object. Usage: with swap_item(obj, "item", 5):
...
This will set obj["item"] to 5 for the duration of the with block, restoring the old value at the end of the block. If item doesn’t exist on obj, it will be created and the... | python.library.test#test.support.swap_item |
test.support.system_must_validate_cert(f)
Raise unittest.SkipTest on TLS certification validation failures. | python.library.test#test.support.system_must_validate_cert |
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... | python.library.test#test.support.temp_cwd |
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 ca... | python.library.test#test.support.temp_dir |
test.support.temp_umask(umask)
A context manager that temporarily sets the process umask. | python.library.test#test.support.temp_umask |
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. | python.library.test#test.support.TestFailed |
test.support.TESTFN
Set to a name that is safe to use as the name of a temporary file. Any temporary file that is created should be closed and unlinked (removed). | python.library.test#test.support.TESTFN |
test.support.TESTFN_ENCODING
Set to sys.getfilesystemencoding(). | python.library.test#test.support.TESTFN_ENCODING |
test.support.TESTFN_NONASCII
Set to a filename containing the FS_NONASCII character. | python.library.test#test.support.TESTFN_NONASCII |
test.support.TESTFN_UNDECODABLE
Set to a filename (bytes type) that should not be able to be decoded by file system encoding in strict mode. It may be None if it’s not possible to generate such a filename. | python.library.test#test.support.TESTFN_UNDECODABLE |
test.support.TESTFN_UNENCODABLE
Set to a filename (str type) that should not be able to be encoded by file system encoding in strict mode. It may be None if it’s not possible to generate such a filename. | python.library.test#test.support.TESTFN_UNENCODABLE |
test.support.TESTFN_UNICODE
Set to a non-ASCII name for a temporary file. | python.library.test#test.support.TESTFN_UNICODE |
test.support.TEST_DATA_DIR
Set to the data directory within the test package. | python.library.test#test.support.TEST_DATA_DIR |
test.support.TEST_HOME_DIR
Set to the top level directory for the test package. | python.library.test#test.support.TEST_HOME_DIR |
test.support.TEST_HTTP_URL
Define the URL of a dedicated HTTP server for the network tests. | python.library.test#test.support.TEST_HTTP_URL |
test.support.TEST_SUPPORT_DIR
Set to the top level directory that contains test.support. | python.library.test#test.support.TEST_SUPPORT_DIR |
test.support.threading_cleanup(*original_values)
Cleanup up threads not specified in original_values. Designed to emit a warning if a test leaves running threads in the background. | python.library.test#test.support.threading_cleanup |
test.support.threading_setup()
Return current thread count and copy of dangling threads. | python.library.test#test.support.threading_setup |
class test.support.TransientResource(exc, **kwargs)
Instances are a context manager that raises ResourceDenied if the specified exception type is raised. Any keyword arguments are treated as attribute/value pairs to be compared against any exception raised within the with statement. Only if all pairs match properly a... | python.library.test#test.support.TransientResource |
test.support.unix_shell
Path for shell if not on Windows; otherwise None. | python.library.test#test.support.unix_shell |
test.support.unlink(filename)
Call os.unlink() on filename. On Windows platforms, this is wrapped with a wait loop that checks for the existence fo the file. | python.library.test#test.support.unlink |
test.support.unload(name)
Delete name from sys.modules. | python.library.test#test.support.unload |
test.support.verbose
True when verbose output is enabled. Should be checked when more detailed information is desired about a running test. verbose is set by test.regrtest. | python.library.test#test.support.verbose |
test.support.wait_process(pid, *, exitcode, timeout=None)
Wait until process pid completes and check that the process exit code is exitcode. Raise an AssertionError if the process exit code is not equal to exitcode. If the process runs longer than timeout seconds (SHORT_TIMEOUT by default), kill the process and raise... | python.library.test#test.support.wait_process |
test.support.wait_threads_exit(timeout=60.0)
Context manager to wait until all threads created in the with statement exit. | python.library.test#test.support.wait_threads_exit |
class test.support.WarningsRecorder
Class used to record warnings for unit tests. See documentation of check_warnings() above for more details. | python.library.test#test.support.WarningsRecorder |
test.support.with_pymalloc()
Return _testcapi.WITH_PYMALLOC. | python.library.test#test.support.with_pymalloc |
textwrap — Text wrapping and filling Source code: Lib/textwrap.py The textwrap module provides some convenience functions, as well as TextWrapper, the class that does all the work. If you’re just wrapping or filling one or two text strings, the convenience functions should be good enough; otherwise, you should use an i... | python.library.textwrap |
textwrap.dedent(text)
Remove any common leading whitespace from every line in text. This can be used to make triple-quoted strings line up with the left edge of the display, while still presenting them in the source code in indented form. Note that tabs and spaces are both treated as whitespace, but they are not equa... | python.library.textwrap#textwrap.dedent |
textwrap.fill(text, width=70, **kwargs)
Wraps the single paragraph in text, and returns a single string containing the wrapped paragraph. fill() is shorthand for "\n".join(wrap(text, ...))
In particular, fill() accepts exactly the same keyword arguments as wrap(). | python.library.textwrap#textwrap.fill |
textwrap.indent(text, prefix, predicate=None)
Add prefix to the beginning of selected lines in text. Lines are separated by calling text.splitlines(True). By default, prefix is added to all lines that do not consist solely of whitespace (including any line endings). For example: >>> s = 'hello\n\n \nworld'
>>> indent... | python.library.textwrap#textwrap.indent |
textwrap.shorten(text, width, **kwargs)
Collapse and truncate the given text to fit in the given width. First the whitespace in text is collapsed (all whitespace is replaced by single spaces). If the result fits in the width, it is returned. Otherwise, enough words are dropped from the end so that the remaining words... | python.library.textwrap#textwrap.shorten |
class textwrap.TextWrapper(**kwargs)
The TextWrapper constructor accepts a number of optional keyword arguments. Each keyword argument corresponds to an instance attribute, so for example wrapper = TextWrapper(initial_indent="* ")
is the same as wrapper = TextWrapper()
wrapper.initial_indent = "* "
You can re-use t... | python.library.textwrap#textwrap.TextWrapper |
break_long_words
(default: True) If true, then words longer than width will be broken in order to ensure that no lines are longer than width. If it is false, long words will not be broken, and some lines may be longer than width. (Long words will be put on a line by themselves, in order to minimize the amount by whic... | python.library.textwrap#textwrap.TextWrapper.break_long_words |
break_on_hyphens
(default: True) If true, wrapping will occur preferably on whitespaces and right after hyphens in compound words, as it is customary in English. If false, only whitespaces will be considered as potentially good places for line breaks, but you need to set break_long_words to false if you want truly in... | python.library.textwrap#textwrap.TextWrapper.break_on_hyphens |
drop_whitespace
(default: True) If true, whitespace at the beginning and ending of every line (after wrapping but before indenting) is dropped. Whitespace at the beginning of the paragraph, however, is not dropped if non-whitespace follows it. If whitespace being dropped takes up an entire line, the whole line is dro... | python.library.textwrap#textwrap.TextWrapper.drop_whitespace |
expand_tabs
(default: True) If true, then all tab characters in text will be expanded to spaces using the expandtabs() method of text. | python.library.textwrap#textwrap.TextWrapper.expand_tabs |
fill(text)
Wraps the single paragraph in text, and returns a single string containing the wrapped paragraph. | python.library.textwrap#textwrap.TextWrapper.fill |
fix_sentence_endings
(default: False) If true, TextWrapper attempts to detect sentence endings and ensure that sentences are always separated by exactly two spaces. This is generally desired for text in a monospaced font. However, the sentence detection algorithm is imperfect: it assumes that a sentence ending consis... | python.library.textwrap#textwrap.TextWrapper.fix_sentence_endings |
initial_indent
(default: '') String that will be prepended to the first line of wrapped output. Counts towards the length of the first line. The empty string is not indented. | python.library.textwrap#textwrap.TextWrapper.initial_indent |
max_lines
(default: None) If not None, then the output will contain at most max_lines lines, with placeholder appearing at the end of the output. New in version 3.4. | python.library.textwrap#textwrap.TextWrapper.max_lines |
placeholder
(default: ' [...]') String that will appear at the end of the output text if it has been truncated. New in version 3.4. | python.library.textwrap#textwrap.TextWrapper.placeholder |
replace_whitespace
(default: True) If true, after tab expansion but before wrapping, the wrap() method will replace each whitespace character with a single space. The whitespace characters replaced are as follows: tab, newline, vertical tab, formfeed, and carriage return ('\t\n\v\f\r'). Note If expand_tabs is false ... | python.library.textwrap#textwrap.TextWrapper.replace_whitespace |
subsequent_indent
(default: '') String that will be prepended to all lines of wrapped output except the first. Counts towards the length of each line except the first. | python.library.textwrap#textwrap.TextWrapper.subsequent_indent |
tabsize
(default: 8) If expand_tabs is true, then all tab characters in text will be expanded to zero or more spaces, depending on the current column and the given tab size. New in version 3.3. | python.library.textwrap#textwrap.TextWrapper.tabsize |
width
(default: 70) The maximum length of wrapped lines. As long as there are no individual words in the input text longer than width, TextWrapper guarantees that no output line will be longer than width characters. | python.library.textwrap#textwrap.TextWrapper.width |
wrap(text)
Wraps the single paragraph in text (a string) so every line is at most width characters long. All wrapping options are taken from instance attributes of the TextWrapper instance. Returns a list of output lines, without final newlines. If the wrapped output has no content, the returned list is empty. | python.library.textwrap#textwrap.TextWrapper.wrap |
textwrap.wrap(text, width=70, **kwargs)
Wraps the single paragraph in text (a string) so every line is at most width characters long. Returns a list of output lines, without final newlines. Optional keyword arguments correspond to the instance attributes of TextWrapper, documented below. width defaults to 70. See the... | python.library.textwrap#textwrap.wrap |
threading — Thread-based parallelism Source code: Lib/threading.py This module constructs higher-level threading interfaces on top of the lower level _thread module. See also the queue module. Changed in version 3.7: This module used to be optional, it is now always available. Note While they are not listed below, t... | python.library.threading |
threading.active_count()
Return the number of Thread objects currently alive. The returned count is equal to the length of the list returned by enumerate(). | python.library.threading#threading.active_count |
class threading.Barrier(parties, action=None, timeout=None)
Create a barrier object for parties number of threads. An action, when provided, is a callable to be called by one of the threads when they are released. timeout is the default timeout value if none is specified for the wait() method.
wait(timeout=None)
... | python.library.threading#threading.Barrier |
abort()
Put the barrier into a broken state. This causes any active or future calls to wait() to fail with the BrokenBarrierError. Use this for example if one of the threads needs to abort, to avoid deadlocking the application. It may be preferable to simply create the barrier with a sensible timeout value to automat... | python.library.threading#threading.Barrier.abort |
broken
A boolean that is True if the barrier is in the broken state. | python.library.threading#threading.Barrier.broken |
n_waiting
The number of threads currently waiting in the barrier. | python.library.threading#threading.Barrier.n_waiting |
parties
The number of threads required to pass the barrier. | python.library.threading#threading.Barrier.parties |
reset()
Return the barrier to the default, empty state. Any threads waiting on it will receive the BrokenBarrierError exception. Note that using this function may require some external synchronization if there are other threads whose state is unknown. If a barrier is broken it may be better to just leave it and creat... | python.library.threading#threading.Barrier.reset |
wait(timeout=None)
Pass the barrier. When all the threads party to the barrier have called this function, they are all released simultaneously. If a timeout is provided, it is used in preference to any that was supplied to the class constructor. The return value is an integer in the range 0 to parties – 1, different ... | python.library.threading#threading.Barrier.wait |
class threading.BoundedSemaphore(value=1)
Class implementing bounded semaphore objects. A bounded semaphore checks to make sure its current value doesn’t exceed its initial value. If it does, ValueError is raised. In most situations semaphores are used to guard resources with limited capacity. If the semaphore is rel... | python.library.threading#threading.BoundedSemaphore |
exception threading.BrokenBarrierError
This exception, a subclass of RuntimeError, is raised when the Barrier object is reset or broken. | python.library.threading#threading.BrokenBarrierError |
class threading.Condition(lock=None)
This class implements condition variable objects. A condition variable allows one or more threads to wait until they are notified by another thread. If the lock argument is given and not None, it must be a Lock or RLock object, and it is used as the underlying lock. Otherwise, a n... | python.library.threading#threading.Condition |
acquire(*args)
Acquire the underlying lock. This method calls the corresponding method on the underlying lock; the return value is whatever that method returns. | python.library.threading#threading.Condition.acquire |
notify(n=1)
By default, wake up one thread waiting on this condition, if any. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the threads waiting for the condition variable; it is a no-op if no threads are waiting. The current imp... | python.library.threading#threading.Condition.notify |
notify_all()
Wake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. | python.library.threading#threading.Condition.notify_all |
release()
Release the underlying lock. This method calls the corresponding method on the underlying lock; there is no return value. | python.library.threading#threading.Condition.release |
wait(timeout=None)
Wait until notified or until a timeout occurs. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in a... | python.library.threading#threading.Condition.wait |
wait_for(predicate, timeout=None)
Wait until a condition evaluates to true. predicate should be a callable which result will be interpreted as a boolean value. A timeout may be provided giving the maximum time to wait. This utility method may call wait() repeatedly until the predicate is satisfied, or until a timeout... | python.library.threading#threading.Condition.wait_for |
threading.current_thread()
Return the current Thread object, corresponding to the caller’s thread of control. If the caller’s thread of control was not created through the threading module, a dummy thread object with limited functionality is returned. | python.library.threading#threading.current_thread |
threading.enumerate()
Return a list of all Thread objects currently alive. The list includes daemonic threads, dummy thread objects created by current_thread(), and the main thread. It excludes terminated threads and threads that have not yet been started. | python.library.threading#threading.enumerate |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.