Skip to content

Commit

Permalink
change separator to hyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Apr 5, 2019
1 parent 37ecca3 commit 1597044
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
16 changes: 6 additions & 10 deletions src/_pytest/skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,8 @@ def _get_line_with_reprcrash_message(config, rep, termwidth):
pos = _get_pos(config, rep)

line = "%s %s" % (verbose_word, pos)

len_line = len(line)
ellipsis = "..."
len_ellipsis = len(ellipsis)

ellipsis, len_ellipsis = "...", 3
if len_line > termwidth - len_ellipsis:
# No space for an additional message.
return line
Expand All @@ -230,12 +227,11 @@ def _get_line_with_reprcrash_message(config, rep, termwidth):
msg = msg[:i]
len_msg = len(msg)

sep = ": "
len_sep = len(sep)
max_len = termwidth - len_line - len_sep
if max_len >= len_ellipsis:
if len_msg > max_len:
msg = msg[: (max_len - len_ellipsis)] + ellipsis
sep, len_sep = " - ", 3
max_len_msg = termwidth - len_line - len_sep
if max_len_msg >= len_ellipsis:
if len_msg > max_len_msg:
msg = msg[: (max_len_msg - len_ellipsis)] + ellipsis
line += sep + msg
return line

Expand Down
20 changes: 10 additions & 10 deletions testing/test_skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ def test_fail():
[
"=* FAILURES *=",
"*= short test summary info =*",
"FAILED test_summary_list_after_errors.py::test_fail: assert 0",
"FAILED test_summary_list_after_errors.py::test_fail - assert 0",
]
)

Expand Down Expand Up @@ -1240,18 +1240,18 @@ class longrepr:
class reprcrash:
message = "msg"

assert f(config, rep, 80) == "FAILED some::nodeid: msg"
assert f(config, rep, 80) == "FAILED some::nodeid - msg"
assert f(config, rep, 3) == "FAILED some::nodeid"

assert f(config, rep, 23) == "FAILED some::nodeid"
assert f(config, rep, 24) == "FAILED some::nodeid: msg"
assert f(config, rep, 24) == "FAILED some::nodeid"
assert f(config, rep, 25) == "FAILED some::nodeid - msg"

rep.longrepr.reprcrash.message = "some longer message"
assert f(config, rep, 23) == "FAILED some::nodeid"
assert f(config, rep, 24) == "FAILED some::nodeid: ..."
assert f(config, rep, 25) == "FAILED some::nodeid: s..."
assert f(config, rep, 24) == "FAILED some::nodeid"
assert f(config, rep, 25) == "FAILED some::nodeid - ..."
assert f(config, rep, 26) == "FAILED some::nodeid - s..."

rep.longrepr.reprcrash.message = "some\nmessage"
assert f(config, rep, 24) == "FAILED some::nodeid: ..."
assert f(config, rep, 25) == "FAILED some::nodeid: some"
assert f(config, rep, 80) == "FAILED some::nodeid: some"
assert f(config, rep, 25) == "FAILED some::nodeid - ..."
assert f(config, rep, 26) == "FAILED some::nodeid - some"
assert f(config, rep, 80) == "FAILED some::nodeid - some"
2 changes: 1 addition & 1 deletion testing/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ def test_fail_extra_reporting(testdir, monkeypatch):
result.stdout.fnmatch_lines(
[
"*test summary*",
"FAILED test_fail_extra_reporting.py::test_this: AssertionError: this_failedth...",
"FAILED test_fail_extra_reporting.py::test_this - AssertionError: this_failedt...",
]
)

Expand Down

0 comments on commit 1597044

Please sign in to comment.