summaryrefslogtreecommitdiff
path: root/testing/test_recwarn.py
diff options
context:
space:
mode:
authorLoïc Estève <loic.esteve@ymail.com>2016-12-20 14:57:48 +0100
committerBruno Oliveira <nicoddemus@gmail.com>2017-01-03 10:57:19 -0200
commit6fd0394c6317dc8acf2d1c58e2bad2379703214a (patch)
treeb207cdae60adc40e4e480df6f42947dfdbb720e3 /testing/test_recwarn.py
parent8f1450114f2b7f147d022db4535f14645beebc3b (diff)
downloadpytest-6fd0394c6317dc8acf2d1c58e2bad2379703214a.tar.gz
pytest.warns checks for subclass relationship
rather than class equality. This makes it more similar to pytest.raises.
Diffstat (limited to 'testing/test_recwarn.py')
-rw-r--r--testing/test_recwarn.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py
index 6c4d73ff7..ef2ebd74c 100644
--- a/testing/test_recwarn.py
+++ b/testing/test_recwarn.py
@@ -238,6 +238,16 @@ class TestWarns(object):
assert str(record[0].message) == "user"
assert str(record[1].message) == "runtime"
+ def test_record_by_subclass(self):
+ with pytest.warns(Warning) as record:
+ warnings.warn("user", UserWarning)
+ warnings.warn("runtime", RuntimeWarning)
+
+ 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"""
testdir.makepyfile('''