Skip to content

Commit fa418c9

Browse files
committed
Add a test when multiple classes are specified in warns
1 parent 6173120 commit fa418c9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

testing/test_recwarn.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ def test_record_by_subclass(self):
247247
assert str(record[0].message) == "user"
248248
assert str(record[1].message) == "runtime"
249249

250+
class MyUserWarning(UserWarning): pass
251+
class MyRuntimeWarning(RuntimeWarning): pass
252+
253+
with pytest.warns((UserWarning, RuntimeWarning)) as record:
254+
warnings.warn("user", MyUserWarning)
255+
warnings.warn("runtime", MyRuntimeWarning)
256+
257+
assert len(record) == 2
258+
assert str(record[0].message) == "user"
259+
assert str(record[1].message) == "runtime"
260+
250261

251262
def test_double_test(self, testdir):
252263
"""If a test is run again, the warning should still be raised"""

0 commit comments

Comments
 (0)