Re-added _surrounding_parens_on_own_lines(), and fixed test cases related to issue #10863 to account for new changes from main

This commit is contained in:
JamieC2002 2023-12-07 20:21:04 -05:00
parent 1741952b49
commit 7459535127
2 changed files with 24 additions and 3 deletions

View File

@ -338,8 +338,8 @@ def _compare_eq_iterable(
lines_right = len(right_formatting)
if lines_left > 1 or lines_right > 1:
_surrounding_parens_on_own_lines(left_formatting)
_surrounding_parens_on_own_lines(right_formatting)
_surrounding_parens_on_own_lines(left_formatting)
_surrounding_parens_on_own_lines(right_formatting)
else:
left_formatting = PrettyPrinter().pformat(left).splitlines()
right_formatting = PrettyPrinter().pformat(right).splitlines()
@ -359,6 +359,18 @@ def _compare_eq_iterable(
return explanation
def _surrounding_parens_on_own_lines(lines: List[str]) -> None:
"""Move opening/closing parenthesis/bracket to own lines."""
opening = lines[0][:1]
if opening in ["(", "[", "{"]:
lines[0] = " " + lines[0][1:]
lines[:] = [opening] + lines
closing = lines[-1][-1:]
if closing in [")", "]", "}"]:
lines[-1] = lines[-1][:-1] + ","
lines[:] = lines + [closing]
def _is_empty_vs_non_empty(left: Iterable[Any], right: Iterable[Any]) -> bool:
is_left_empty = not any(left) if isinstance(left, Iterable) else not left
is_right_empty = not any(right) if isinstance(right, Iterable) else not right

View File

@ -416,14 +416,17 @@ class TestAssert_reprcompare:
assert callequal(m1, []) == [
"['This is som...e full diff.'] == []",
"",
"Left contains one more item: 'This is some dummy test which shows the "
"strange way in which Pycharm displays the full diff.'",
"Use -v to get more diff",
]
assert callequal(m1, [], verbose=True) == [
"['This is som...e full diff.'] == []",
"",
"Left contains one more item: 'This is some dummy test which shows the "
"strange way in which Pycharm displays the full diff.'",
"",
"Full diff:",
"- []",
"+ ['This is some dummy test which shows the strange way in which Pycharm "
@ -432,6 +435,7 @@ class TestAssert_reprcompare:
assert callequal(m2, []) == [
"['This is som...e full diff.'] == []",
"",
"Left contains one more item: 'This is some dummy test which shows the "
"strange way in which Pycharm displays the full diff.This is some dummy test "
"which shows the strange way in which Pycharm displays the full diff.'",
@ -440,9 +444,11 @@ class TestAssert_reprcompare:
assert callequal(m2, [], verbose=True) == [
"['This is som...e full diff.'] == []",
"",
"Left contains one more item: 'This is some dummy test which shows the "
"strange way in which Pycharm displays the full diff.This is some dummy test "
"which shows the strange way in which Pycharm displays the full diff.'",
"" "",
"Full diff:",
"- []",
"+ ['This is some dummy test which shows the strange way in which Pycharm "
@ -452,15 +458,18 @@ class TestAssert_reprcompare:
assert callequal(m3, []) == [
"['This is som...e full diff.'] == []",
"",
"Left contains 2 more items, first extra item: 'This is some dummy test which shows the strange way in "
"which Pycharm displays the full diff.'",
"Use -v to get more diff",
"" "Use -v to get more diff",
]
assert callequal(m3, [], verbose=True) == [
"['This is som...e full diff.'] == []",
"",
"Left contains 2 more items, first extra item: 'This is some dummy test which shows the strange way in "
"which Pycharm displays the full diff.'",
"",
"Full diff:",
" [",
"- ,",