diff options
author | Matthew Duck <matt@mattduck.com> | 2016-09-19 14:19:34 +0100 |
---|---|---|
committer | Matthew Duck <matt@mattduck.com> | 2016-09-19 15:27:38 +0100 |
commit | 999e7c65417f1e97fc89bf66e0da4c5cd84442ec (patch) | |
tree | 9347d91b96ae4f578edb23dc82c8431421a0122e /_pytest/assertion | |
parent | dd64d823b90f87fca2bb77a61da0912d91f8d7ea (diff) | |
download | pytest-999e7c65417f1e97fc89bf66e0da4c5cd84442ec.tar.gz |
Tidy formatting of assertion truncation
Part two of https://github.com/pytest-dev/pytest/issues/1512. Update the format
of the truncation message to help make it clear that pytest truncates the
entire assertion output when verbosity < 2.
Diffstat (limited to '_pytest/assertion')
-rw-r--r-- | _pytest/assertion/__init__.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py index fd1ebe2c1..e7f0e58ed 100644 --- a/_pytest/assertion/__init__.py +++ b/_pytest/assertion/__init__.py @@ -131,14 +131,21 @@ def pytest_runtest_setup(item): config=item.config, op=op, left=left, right=right) for new_expl in hook_result: if new_expl: + + # Truncate lines if required if (sum(len(p) for p in new_expl[1:]) > 80*8 and item.config.option.verbose < 2 and not _running_on_ci()): show_max = 10 - truncated_lines = len(new_expl) - show_max - new_expl[show_max:] = [py.builtin._totext( - 'Detailed information truncated (%d more lines)' - ', use "-vv" to show' % truncated_lines)] + truncated_count = len(new_expl) - show_max + new_expl[show_max - 1] += " ..." + new_expl[show_max:] = [ + py.builtin._totext(""), + py.builtin._totext('...Full output truncated (%d more lines)' + ', use "-vv" to show' % truncated_count + ), + ] + new_expl = [line.replace("\n", "\\n") for line in new_expl] res = py.builtin._totext("\n~").join(new_expl) if item.config.getvalue("assertmode") == "rewrite": |