diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index ef2ebd74c..8a7edcddb 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -247,6 +247,17 @@ class TestWarns(object): 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"""