Follow Ronny's advice and use ``type`` in ``base_type``.
This commit is contained in:
parent
0cd74dc324
commit
846d91fb95
|
@ -2,6 +2,7 @@ import math
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
from six import binary_type, text_type
|
||||||
from six.moves import zip, filterfalse
|
from six.moves import zip, filterfalse
|
||||||
from more_itertools.more import always_iterable
|
from more_itertools.more import always_iterable
|
||||||
|
|
||||||
|
@ -584,11 +585,11 @@ def raises(expected_exception, *args, **kwargs):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
__tracebackhide__ = True
|
__tracebackhide__ = True
|
||||||
if not isclass(expected_exception) or not issubclass(expected_exception, BaseException):
|
base_type = (type, text_type, binary_type)
|
||||||
for exc in filterfalse(isclass, always_iterable(expected_exception)):
|
for exc in filterfalse(isclass, always_iterable(expected_exception, base_type)):
|
||||||
msg = ("exceptions must be old-style classes or"
|
msg = ("exceptions must be old-style classes or"
|
||||||
" derived from BaseException, not %s")
|
" derived from BaseException, not %s")
|
||||||
raise TypeError(msg % type(exc))
|
raise TypeError(msg % type(exc))
|
||||||
|
|
||||||
message = "DID NOT RAISE {0}".format(expected_exception)
|
message = "DID NOT RAISE {0}".format(expected_exception)
|
||||||
match_expr = None
|
match_expr = None
|
||||||
|
|
Loading…
Reference in New Issue