Warnings always raised in WarningsRecorder

This ensures that if tests for warnings are run more than once,
the warning is still raised as expected.
This commit is contained in:
Eric Hunsberger
2015-08-06 15:05:01 -04:00
parent 02e742b7a6
commit 39f1471e93
2 changed files with 12 additions and 2 deletions

View File

@@ -167,3 +167,9 @@ class TestWarns(object):
assert len(record) == 2
assert str(record[0].message) == "user"
assert str(record[1].message) == "runtime"
@pytest.mark.parametrize('run', [1, 2])
def test_doubletest(self, run):
"""If a test is run again, the warning should still be raised"""
with pytest.warns(RuntimeWarning):
warnings.warn("runtime", RuntimeWarning)