From fa418c93baea7d804aabe23be48a92c40359aee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= Date: Thu, 29 Dec 2016 09:34:21 +0100 Subject: [PATCH] Add a test when multiple classes are specified in warns --- testing/test_recwarn.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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"""