diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-04-02 22:38:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-02 22:38:58 (GMT) |
commit | 9a8ce957482e0d811be6ec2987e99a1f4be3558a (patch) | |
tree | db513ff88e90a8fc3af50c35cb7eca720cc5e3a5 /Doc | |
parent | d58ff6a616276c205e480225f588140f480271b7 (diff) | |
download | cpython-9a8ce957482e0d811be6ec2987e99a1f4be3558a.zip cpython-9a8ce957482e0d811be6ec2987e99a1f4be3558a.tar.gz cpython-9a8ce957482e0d811be6ec2987e99a1f4be3558a.tar.bz2 |
gh-103109: Document ignore_warnings() test support helper (GH-103110)
(cherry picked from commit 32937d6aa414ec7db5c63ef277f21db1880b3af4)
Co-authored-by: Charlie Zhao <zhaoyu_hit@qq.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/test.rst | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Doc/library/test.rst b/Doc/library/test.rst index 922a8f0..700d396 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -1622,6 +1622,21 @@ The :mod:`test.support.warnings_helper` module provides support for warnings tes .. versionadded:: 3.10 +.. function:: ignore_warnings(*, category) + + Suppress warnings that are instances of *category*, + which must be :exc:`Warning` or a subclass. + Roughly equivalent to :func:`warnings.catch_warnings` + with :meth:`warnings.simplefilter('ignore', category=category) <warnings.simplefilter>`. + For example:: + + @warning_helper.ignore_warnings(category=DeprecationWarning) + def test_suppress_warning(): + # do something + + .. versionadded:: 3.8 + + .. function:: check_no_resource_warning(testcase) Context manager to check that no :exc:`ResourceWarning` was raised. You |