Skip to content

Commit

Permalink
Add a test with custom classes
Browse files Browse the repository at this point in the history
  • Loading branch information
lesteve committed Dec 29, 2016
1 parent 6173120 commit babbff4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions testing/test_recwarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ def test_record_by_subclass(self):
assert str(record[0].message) == "user"
assert str(record[1].message) == "runtime"

class MyUserWarning1(UserWarning): pass
class MyUserWarning2(UserWarning): pass

with pytest.warns(UserWarning) as record:
warnings.warn("user 1", MyUserWarning1)
warnings.warn("user 2", MyUserWarning2)

assert len(record) == 2
assert str(record[0].message) == "user 1"
assert str(record[1].message) == "user 2"


def test_double_test(self, testdir):
"""If a test is run again, the warning should still be raised"""
Expand Down

0 comments on commit babbff4

Please sign in to comment.