diff options
author | Omer Hadari <hadari.omer@gmail.com> | 2017-03-04 10:26:46 +0200 |
---|---|---|
committer | Omer Hadari <hadari.omer@gmail.com> | 2017-03-04 10:26:46 +0200 |
commit | 6a52fe165070dcbeda9b7c5b622975effcab5f40 (patch) | |
tree | f2f5776a44255a88a1d3c24764d4fdb0b119d5c8 /_pytest/_code/code.py | |
parent | 5721d8aed1f55703588923f5828ca49e731bc8bd (diff) | |
download | pytest-6a52fe165070dcbeda9b7c5b622975effcab5f40.tar.gz |
fixed internal error on unprintable raised AssertionErrors
Diffstat (limited to '_pytest/_code/code.py')
-rw-r--r-- | _pytest/_code/code.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py index 616d5c431..6eceb0c7f 100644 --- a/_pytest/_code/code.py +++ b/_pytest/_code/code.py @@ -352,6 +352,8 @@ class ExceptionInfo(object): help for navigating the traceback. """ _striptext = '' + _assert_start_repr = "AssertionError(u\'assert " if sys.version_info[0] < 3 else "AssertionError(\'assert " + def __init__(self, tup=None, exprinfo=None): import _pytest._code if tup is None: @@ -359,8 +361,8 @@ class ExceptionInfo(object): if exprinfo is None and isinstance(tup[1], AssertionError): exprinfo = getattr(tup[1], 'msg', None) if exprinfo is None: - exprinfo = py._builtin._totext(tup[1]) - if exprinfo and exprinfo.startswith('assert '): + exprinfo = py.io.saferepr(tup[1]) + if exprinfo and exprinfo.startswith(self._assert_start_repr): self._striptext = 'AssertionError: ' self._excinfo = tup #: the exception class |