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.
This commit is contained in:
parent
dd64d823b9
commit
999e7c6541
|
@ -131,14 +131,21 @@ def pytest_runtest_setup(item):
|
||||||
config=item.config, op=op, left=left, right=right)
|
config=item.config, op=op, left=left, right=right)
|
||||||
for new_expl in hook_result:
|
for new_expl in hook_result:
|
||||||
if new_expl:
|
if new_expl:
|
||||||
|
|
||||||
|
# Truncate lines if required
|
||||||
if (sum(len(p) for p in new_expl[1:]) > 80*8 and
|
if (sum(len(p) for p in new_expl[1:]) > 80*8 and
|
||||||
item.config.option.verbose < 2 and
|
item.config.option.verbose < 2 and
|
||||||
not _running_on_ci()):
|
not _running_on_ci()):
|
||||||
show_max = 10
|
show_max = 10
|
||||||
truncated_lines = len(new_expl) - show_max
|
truncated_count = len(new_expl) - show_max
|
||||||
new_expl[show_max:] = [py.builtin._totext(
|
new_expl[show_max - 1] += " ..."
|
||||||
'Detailed information truncated (%d more lines)'
|
new_expl[show_max:] = [
|
||||||
', use "-vv" to show' % truncated_lines)]
|
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]
|
new_expl = [line.replace("\n", "\\n") for line in new_expl]
|
||||||
res = py.builtin._totext("\n~").join(new_expl)
|
res = py.builtin._totext("\n~").join(new_expl)
|
||||||
if item.config.getvalue("assertmode") == "rewrite":
|
if item.config.getvalue("assertmode") == "rewrite":
|
||||||
|
|
Loading…
Reference in New Issue