Add a test when multiple classes are specified in warns

This commit is contained in:
Loïc Estève
2016-12-29 09:34:21 +01:00
committed by Bruno Oliveira
parent 56d1858ea2
commit 0bd8159b60

View File

@@ -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"""