summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/test.rst15
-rw-r--r--Lib/test/support/warnings_helper.py2
2 files changed, 16 insertions, 1 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
diff --git a/Lib/test/support/warnings_helper.py b/Lib/test/support/warnings_helper.py
index a024fbe..93a91e6 100644
--- a/Lib/test/support/warnings_helper.py
+++ b/Lib/test/support/warnings_helper.py
@@ -36,7 +36,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.