Skip to content

Commit 0854bdf

Browse files
miss-islingtonCharlieZhao95CAM-Gerlach
authored
gh-103109: Document ignore_warnings() test support helper (GH-103110)
(cherry picked from commit 32937d6) Co-authored-by: Charlie Zhao <[email protected]> Co-authored-by: C.A.M. Gerlach <[email protected]>
1 parent 4664a7c commit 0854bdf

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Doc/library/test.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,21 @@ The :mod:`test.support.warnings_helper` module provides support for warnings tes
16311631
.. versionadded:: 3.10
16321632

16331633

1634+
.. function:: ignore_warnings(*, category)
1635+
1636+
Suppress warnings that are instances of *category*,
1637+
which must be :exc:`Warning` or a subclass.
1638+
Roughly equivalent to :func:`warnings.catch_warnings`
1639+
with :meth:`warnings.simplefilter('ignore', category=category) <warnings.simplefilter>`.
1640+
For example::
1641+
1642+
@warning_helper.ignore_warnings(category=DeprecationWarning)
1643+
def test_suppress_warning():
1644+
# do something
1645+
1646+
.. versionadded:: 3.8
1647+
1648+
16341649
.. function:: check_no_resource_warning(testcase)
16351650

16361651
Context manager to check that no :exc:`ResourceWarning` was raised. You

Lib/test/support/warnings_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def check_syntax_warning(testcase, statement, errtext='',
4444

4545

4646
def ignore_warnings(*, category):
47-
"""Decorator to suppress deprecation warnings.
47+
"""Decorator to suppress warnings.
4848
4949
Use of context managers to hide warnings make diffs
5050
more noisy and tools like 'git blame' less useful.

0 commit comments

Comments
 (0)