diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index aa96ee43f..e2a30dd39 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -1158,6 +1158,10 @@ class ReprEntry(TerminalRepr): if is_failure_line: # from this point on all lines are considered part of the failure failure_lines.extend(self.lines[index:]) + + for line in self.lines[index:]: + print(line) + break else: if self.style == "value": @@ -1180,6 +1184,8 @@ class ReprEntry(TerminalRepr): for line in failure_lines: line_list = line.split() # multiline case seems to be an issue with just an added ',' + # print(line_list) + # These are edge cases for empty lists if len(line_list) == 3 and line_list[2] == "," and line_list[1] == "-": line = line.replace(",", "[]") # This is to remove the extra whitespace between '-' and '[]' @@ -1187,6 +1193,14 @@ class ReprEntry(TerminalRepr): extra_wp_i = line_list.index("-") + 1 line_list.pop(extra_wp_i) line = "".join(line_list) + elif len(line_list) == 3 and line_list[2] == "," and line_list[1] == "+": + line = line.replace(",", "[]") + # This is to remove the extra whitespace between '+' and '[]' + line_list = list(line) + extra_wp_i = line_list.index("+") + 1 + line_list.pop(extra_wp_i) + line = "".join(line_list) + # print(line) tw.line(line, bold=True, red=True) def toterminal(self, tw: TerminalWriter) -> None: diff --git a/testing/examples/my_test.py b/testing/examples/my_test.py index c4763bc70..3c6edde0e 100644 --- a/testing/examples/my_test.py +++ b/testing/examples/my_test.py @@ -10,13 +10,13 @@ def test2_(): m = [ "This is another check" " This line and the line above should be fine" - " Same with this line" - " But we should not see the '- ,' appear" - " But rather we should see a '- []' appear" + "Same with this line" + "But we should not see the '- ,' appear" + "But rather we should see a '- []' appear" ] - assert m == [] + assert [] == m -def test3_(): - m = ["This is some dummy test which shows the strange way in which Pycharm"] - assert m == [] +# def test3_(): +# m = ["This is some dummy test which shows the strange way in which Pycharm"] +# assert m == []