Merge pull request #1439 from pytest-dev/fix-1178

Support pytest.fail with non-ascii characters

Fixes #1178
This commit is contained in:
Ronny Pfannschmidt
2016-03-06 06:42:35 +01:00
4 changed files with 31 additions and 2 deletions

View File

@@ -740,7 +740,7 @@ class FunctionMixin(PyobjMixin):
def _repr_failure_py(self, excinfo, style="long"):
if excinfo.errisinstance(pytest.fail.Exception):
if not excinfo.value.pytrace:
return str(excinfo.value)
return py._builtin._totext(excinfo.value)
return super(FunctionMixin, self)._repr_failure_py(excinfo,
style=style)

View File

@@ -435,7 +435,10 @@ class OutcomeException(Exception):
def __repr__(self):
if self.msg:
return str(self.msg)
val = self.msg
if isinstance(val, bytes):
val = py._builtin._totext(val, errors='replace')
return val
return "<%s instance>" %(self.__class__.__name__,)
__str__ = __repr__