Skip to content

Commit e325707

Browse files
committed
Fixed issues from removal of pytest.warns(None) in pytest version 8
Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
1 parent 5c35e0a commit e325707

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

docs/changes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Released: not yet
2020

2121
* Removed unneeded backslashes reported by new Pylint version.
2222

23+
* Test: Fixed issues resulting from removal of support for pytest.warns(None)
24+
in pytest version 8.
25+
2326

2427
nocaselist 1.1.2
2528
----------------

tests/utils/simplified_test_function.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from __future__ import absolute_import
66

77
import functools
8+
import warnings
89
from collections import namedtuple
910
try:
1011
from inspect import Signature, Parameter
@@ -151,7 +152,7 @@ def wrapper_func(desc, kwargs, exp_exc_types, exp_warn_types, condition):
151152
ret = None # Debugging hint
152153
assert len(rec_warnings) >= 1
153154
else:
154-
with pytest.warns(None) as rec_warnings:
155+
with warnings.catch_warnings(record=True) as rec_warnings:
155156
if exp_exc_types:
156157
with pytest.raises(exp_exc_types):
157158
if condition == 'pdb':
@@ -173,7 +174,7 @@ def wrapper_func(desc, kwargs, exp_exc_types, exp_warn_types, condition):
173174
# Verify that no warnings have occurred
174175
if exp_warn_types is None and rec_warnings:
175176
lines = []
176-
for w in rec_warnings.list:
177+
for w in rec_warnings:
177178
tup = (w.filename, w.lineno, w.category.__name__,
178179
str(w.message))
179180
line = "{t[0]}:{t[1]}: {t[2]}: {t[3]}".format(t=tup)

0 commit comments

Comments
 (0)