Skip to content

Commit 32937d6

Browse files
gh-103109: Document ignore_warnings() test support helper (#103110)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
1 parent 6883007 commit 32937d6

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
@@ -1691,6 +1691,21 @@ The :mod:`test.support.warnings_helper` module provides support for warnings tes
16911691
.. versionadded:: 3.10
16921692

16931693

1694+
.. function:: ignore_warnings(*, category)
1695+
1696+
Suppress warnings that are instances of *category*,
1697+
which must be :exc:`Warning` or a subclass.
1698+
Roughly equivalent to :func:`warnings.catch_warnings`
1699+
with :meth:`warnings.simplefilter('ignore', category=category) <warnings.simplefilter>`.
1700+
For example::
1701+
1702+
@warning_helper.ignore_warnings(category=DeprecationWarning)
1703+
def test_suppress_warning():
1704+
# do something
1705+
1706+
.. versionadded:: 3.8
1707+
1708+
16941709
.. function:: check_no_resource_warning(testcase)
16951710

16961711
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)