Add a test when multiple classes are specified in warns
This commit is contained in:
parent
56d1858ea2
commit
0bd8159b60
|
@ -247,6 +247,17 @@ class TestWarns(object):
|
||||||
assert str(record[0].message) == "user"
|
assert str(record[0].message) == "user"
|
||||||
assert str(record[1].message) == "runtime"
|
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):
|
def test_double_test(self, testdir):
|
||||||
"""If a test is run again, the warning should still be raised"""
|
"""If a test is run again, the warning should still be raised"""
|
||||||
|
|
Loading…
Reference in New Issue