use safe_str to serialize Exceptions Fixes #5478
This commit is contained in:
parent
554bff8cc1
commit
013d0e66c7
|
@ -0,0 +1 @@
|
||||||
|
Use safe_str to serialize Exceptions in pytest.raises
|
|
@ -572,8 +572,9 @@ class ExceptionInfo(object):
|
||||||
raised.
|
raised.
|
||||||
"""
|
"""
|
||||||
__tracebackhide__ = True
|
__tracebackhide__ = True
|
||||||
if not re.search(regexp, str(self.value)):
|
value = safe_str(self.value)
|
||||||
assert 0, "Pattern '{!s}' not found in '{!s}'".format(regexp, self.value)
|
if not re.search(regexp, value):
|
||||||
|
assert 0, "Pattern '{!s}' not found in '{!s}'".format(regexp, value)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -278,3 +278,7 @@ class TestRaises(object):
|
||||||
with pytest.raises(CrappyClass()):
|
with pytest.raises(CrappyClass()):
|
||||||
pass
|
pass
|
||||||
assert "via __class__" in excinfo.value.args[0]
|
assert "via __class__" in excinfo.value.args[0]
|
||||||
|
|
||||||
|
def test_u(self):
|
||||||
|
with pytest.raises(AssertionError, match=u"\u2603"):
|
||||||
|
assert False, u"\u2603"
|
||||||
|
|
Loading…
Reference in New Issue