diff options
author | Tim Strazny <tim.strazny@energymeteo.de> | 2018-04-06 14:16:12 +0200 |
---|---|---|
committer | Tim Strazny <tim.strazny@energymeteo.de> | 2018-04-06 14:16:12 +0200 |
commit | ec2d8223cff2fe83119d142c3b4b365786b3182d (patch) | |
tree | 7a986797a6084da944a86a1a45ed4e833061fd54 /testing | |
parent | 5d4fe87b729bd8ccc5f1e7458e6f48d79a48b514 (diff) | |
download | pytest-ec2d8223cff2fe83119d142c3b4b365786b3182d.tar.gz |
Fix issue #3372
Diffstat (limited to 'testing')
-rw-r--r-- | testing/python/raises.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/python/raises.py b/testing/python/raises.py index 156319816..053426395 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -1,3 +1,4 @@ +from _pytest.outcomes import Failed import pytest import sys @@ -147,3 +148,20 @@ class TestRaises(object): with pytest.raises(ValueError): with pytest.raises(IndexError, match='nomatch'): int('asdf') + + def test_raises_exception_looks_iterable(self): + from six import add_metaclass + + class Meta(type(object)): + def __getitem__(self, item): + return 1/0 + + def __len__(self): + return 1 + + @add_metaclass(Meta) + class ClassLooksIterableException(Exception): + pass + + with pytest.raises(Failed, match="DID NOT RAISE <class 'raises.ClassLooksIterableException'>"): + pytest.raises(ClassLooksIterableException, lambda: None) |