summaryrefslogtreecommitdiff
path: root/tests/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/helpers.py')
-rw-r--r--tests/helpers.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 82d8b18f..c928c01e 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -12,6 +12,7 @@ import re
import shutil
import subprocess
import textwrap
+import warnings
from unittest import mock
@@ -301,3 +302,14 @@ def assert_coverage_warnings(warns, *msgs):
assert expected.search(actual), f"{actual!r} didn't match {expected!r}"
else:
assert expected == actual
+
+
+@contextlib.contextmanager
+def swallow_warnings(message=r".", category=CoverageWarning):
+ """Swallow particular warnings.
+
+ It's OK if they happen, or if they don't happen. Just ignore them.
+ """
+ with warnings.catch_warnings():
+ warnings.filterwarnings("ignore", category=category, message=message)
+ yield