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:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user