This commit is contained in:
Tim Strazny
2018-04-06 14:16:12 +02:00
parent 5d4fe87b72
commit ec2d8223cf
4 changed files with 25 additions and 4 deletions

View File

@@ -584,10 +584,11 @@ def raises(expected_exception, *args, **kwargs):
"""
__tracebackhide__ = True
for exc in filterfalse(isclass, always_iterable(expected_exception)):
msg = ("exceptions must be old-style classes or"
" derived from BaseException, not %s")
raise TypeError(msg % type(exc))
if not issubclass(expected_exception, BaseException):
for exc in filterfalse(isclass, always_iterable(expected_exception)):
msg = ("exceptions must be old-style classes or"
" derived from BaseException, not %s")
raise TypeError(msg % type(exc))
message = "DID NOT RAISE {0}".format(expected_exception)
match_expr = None