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:
parent
1741952b49
commit
7459535127
|
@ -338,8 +338,8 @@ def _compare_eq_iterable(
|
||||||
lines_right = len(right_formatting)
|
lines_right = len(right_formatting)
|
||||||
|
|
||||||
if lines_left > 1 or lines_right > 1:
|
if lines_left > 1 or lines_right > 1:
|
||||||
_surrounding_parens_on_own_lines(left_formatting)
|
_surrounding_parens_on_own_lines(left_formatting)
|
||||||
_surrounding_parens_on_own_lines(right_formatting)
|
_surrounding_parens_on_own_lines(right_formatting)
|
||||||
else:
|
else:
|
||||||
left_formatting = PrettyPrinter().pformat(left).splitlines()
|
left_formatting = PrettyPrinter().pformat(left).splitlines()
|
||||||
right_formatting = PrettyPrinter().pformat(right).splitlines()
|
right_formatting = PrettyPrinter().pformat(right).splitlines()
|
||||||
|
@ -359,6 +359,18 @@ def _compare_eq_iterable(
|
||||||
return explanation
|
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:
|
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_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
|
is_right_empty = not any(right) if isinstance(right, Iterable) else not right
|
||||||
|
|
|
@ -416,14 +416,17 @@ class TestAssert_reprcompare:
|
||||||
|
|
||||||
assert callequal(m1, []) == [
|
assert callequal(m1, []) == [
|
||||||
"['This is som...e full diff.'] == []",
|
"['This is som...e full diff.'] == []",
|
||||||
|
"",
|
||||||
"Left contains one more item: 'This is some dummy test which shows the "
|
"Left contains one more item: 'This is some dummy test which shows the "
|
||||||
"strange way in which Pycharm displays the full diff.'",
|
"strange way in which Pycharm displays the full diff.'",
|
||||||
"Use -v to get more diff",
|
"Use -v to get more diff",
|
||||||
]
|
]
|
||||||
assert callequal(m1, [], verbose=True) == [
|
assert callequal(m1, [], verbose=True) == [
|
||||||
"['This is som...e full diff.'] == []",
|
"['This is som...e full diff.'] == []",
|
||||||
|
"",
|
||||||
"Left contains one more item: 'This is some dummy test which shows the "
|
"Left contains one more item: 'This is some dummy test which shows the "
|
||||||
"strange way in which Pycharm displays the full diff.'",
|
"strange way in which Pycharm displays the full diff.'",
|
||||||
|
"",
|
||||||
"Full diff:",
|
"Full diff:",
|
||||||
"- []",
|
"- []",
|
||||||
"+ ['This is some dummy test which shows the strange way in which Pycharm "
|
"+ ['This is some dummy test which shows the strange way in which Pycharm "
|
||||||
|
@ -432,6 +435,7 @@ class TestAssert_reprcompare:
|
||||||
|
|
||||||
assert callequal(m2, []) == [
|
assert callequal(m2, []) == [
|
||||||
"['This is som...e full diff.'] == []",
|
"['This is som...e full diff.'] == []",
|
||||||
|
"",
|
||||||
"Left contains one more item: 'This is some dummy test which shows the "
|
"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 "
|
"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.'",
|
"which shows the strange way in which Pycharm displays the full diff.'",
|
||||||
|
@ -440,9 +444,11 @@ class TestAssert_reprcompare:
|
||||||
|
|
||||||
assert callequal(m2, [], verbose=True) == [
|
assert callequal(m2, [], verbose=True) == [
|
||||||
"['This is som...e full diff.'] == []",
|
"['This is som...e full diff.'] == []",
|
||||||
|
"",
|
||||||
"Left contains one more item: 'This is some dummy test which shows the "
|
"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 "
|
"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.'",
|
"which shows the strange way in which Pycharm displays the full diff.'",
|
||||||
|
"" "",
|
||||||
"Full diff:",
|
"Full diff:",
|
||||||
"- []",
|
"- []",
|
||||||
"+ ['This is some dummy test which shows the strange way in which Pycharm "
|
"+ ['This is some dummy test which shows the strange way in which Pycharm "
|
||||||
|
@ -452,15 +458,18 @@ class TestAssert_reprcompare:
|
||||||
|
|
||||||
assert callequal(m3, []) == [
|
assert callequal(m3, []) == [
|
||||||
"['This is som...e full diff.'] == []",
|
"['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 "
|
"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.'",
|
"which Pycharm displays the full diff.'",
|
||||||
"Use -v to get more diff",
|
"" "Use -v to get more diff",
|
||||||
]
|
]
|
||||||
|
|
||||||
assert callequal(m3, [], verbose=True) == [
|
assert callequal(m3, [], verbose=True) == [
|
||||||
"['This is som...e full diff.'] == []",
|
"['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 "
|
"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.'",
|
"which Pycharm displays the full diff.'",
|
||||||
|
"",
|
||||||
"Full diff:",
|
"Full diff:",
|
||||||
" [",
|
" [",
|
||||||
"- ,",
|
"- ,",
|
||||||
|
|
Loading…
Reference in New Issue