From 0bd8159b608c57a1467ee1b67b6170335beb6b61 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 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"""