Created
November 21, 2013 15:06
-
-
Save hpk42/7583165 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py | |
| --- a/_pytest/assertion/__init__.py | |
| +++ b/_pytest/assertion/__init__.py | |
| @@ -78,10 +78,12 @@ def pytest_runtest_setup(item): | |
| for new_expl in hook_result: | |
| if new_expl: | |
| - # Don't include pageloads of data unless we are very verbose (-vv) | |
| + # Don't include pageloads of data unless we | |
| + # are very verbose (-vv) | |
| if len(''.join(new_expl[1:])) > 80*8 and item.config.option.verbose < 2: | |
| new_expl[1:] = ['Detailed information truncated, use "-vv" to see'] | |
| - res = '\n~'.join(new_expl) | |
| + res = '\n'.join(new_expl) | |
| + print res | |
| if item.config.getvalue("assertmode") == "rewrite": | |
| # The result will be fed back a python % formatting | |
| # operation, which will fail if there are extraneous | |
| diff --git a/_pytest/assertion/util.py b/_pytest/assertion/util.py | |
| --- a/_pytest/assertion/util.py | |
| +++ b/_pytest/assertion/util.py | |
| @@ -95,9 +95,6 @@ except NameError: | |
| def assertrepr_compare(config, op, left, right): | |
| """Return specialised explanations for some operators/operands""" | |
| width = 80 - 15 - len(op) - 2 # 15 chars indentation, 1 space around op | |
| - left_repr = py.io.saferepr(left, maxsize=int(width/2)) | |
| - right_repr = py.io.saferepr(right, maxsize=width-len(left_repr)) | |
| - summary = '%s %s %s' % (left_repr, op, right_repr) | |
| issequence = lambda x: (isinstance(x, (list, tuple, Sequence)) | |
| and not isinstance(x, basestring)) | |
| @@ -120,9 +117,7 @@ def assertrepr_compare(config, op, left, | |
| elif op == 'not in': | |
| if istext(left) and istext(right): | |
| explanation = _notin_text(left, right, verbose) | |
| - except py.builtin._sysex: | |
| - raise | |
| - except: | |
| + except Exception: | |
| excinfo = py.code.ExceptionInfo() | |
| explanation = [ | |
| '(pytest_assertion plugin: representation of details failed. ' | |
| @@ -130,7 +125,15 @@ def assertrepr_compare(config, op, left, | |
| if not explanation: | |
| return None | |
| - | |
| + if istext(left): | |
| + left_repr = left[:int(width/2)] | |
| + else: | |
| + left_repr = py.io.saferepr(left, maxsize=int(width/2)) | |
| + if istext(right): | |
| + right_repr = right[:int(width/2)] | |
| + else: | |
| + right_repr = py.io.saferepr(right, maxsize=width-len(left_repr)) | |
| + summary = '%s %s %s' % (left_repr, op, right_repr) | |
| return [summary] + explanation | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment