Skip to content

Commit

Permalink
gh-103109: Document ignore_warnings() test support helper (#103110)
Browse files Browse the repository at this point in the history
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
  • Loading branch information
CharlieZhao95 and CAM-Gerlach authored Apr 2, 2023
1 parent 6883007 commit 32937d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Doc/library/test.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,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
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/support/warnings_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def check_syntax_warning(testcase, statement, errtext='',


def ignore_warnings(*, category):
"""Decorator to suppress deprecation warnings.
"""Decorator to suppress warnings.
Use of context managers to hide warnings make diffs
more noisy and tools like 'git blame' less useful.
Expand Down

0 comments on commit 32937d6

Please sign in to comment.