Improve error message if pytest.raises is used wrongly

If the type is not checked then an incomprehensible error will occur
later.  This enforces the type and raies the same exception/msg as
CPython does in that case.

Docstring unmodified, just re-justified for pep8 compat.
This commit is contained in:
Floris Bruynooghe
2014-04-14 18:09:10 -04:00
parent d74f852fd6
commit faba432996
2 changed files with 26 additions and 9 deletions

View File

@@ -62,3 +62,10 @@ class TestRaises:
'*3 passed*',
])
def test_noclass(self):
with pytest.raises(TypeError):
pytest.raises('wrong', lambda: None)
def test_tuple(self):
with pytest.raises((KeyError, ValueError)):
raise KeyError('oops')