diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index ef2ebd74cb4..8a7edcddb0c 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -247,6 +247,17 @@ def test_record_by_subclass(self): assert str(record[0].message) == "user" assert str(record[1].message) == "runtime" + class MyUserWarning(UserWarning): pass + class MyRuntimeWarning(RuntimeWarning): pass + + with pytest.warns((UserWarning, RuntimeWarning)) as record: + warnings.warn("user", MyUserWarning) + warnings.warn("runtime", MyRuntimeWarning) + + assert len(record) == 2 + assert str(record[0].message) == "user" + assert str(record[1].message) == "runtime" + def test_double_test(self, testdir): """If a test is run again, the warning should still be raised"""