FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-103109: Add documentation for `ignore_warnings` by CharlieZhao95 · Pull Request #103110 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 15 additions & 0 deletions Doc/library/test.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
Comment thread
CharlieZhao95 marked this conversation as resolved.

.. 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL