assert: fix _compare_eq_iterable: re-format both sides
Follow-up to 946434c61 (#5924).
Before this patch the test would look like this:
{'env': {'sub...s wrapped'}}}} == {'env': {'sub...}}}, 'new': 1}
Omitting 1 identical items, use -vv to show
Right contains 1 more item:
{'new': 1}
Full diff:
{
'env': {'sub': {'long_a': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
- 'sub1': {'long_a': 'substring '
+ 'sub1': {'long_a': 'substring that gets wrapped'}}},
? +++++++++++++++++ ++++
+ 'new': 1,
- 'that '
- 'gets '
- 'wrapped'}}},
}
This commit is contained in:
@@ -273,12 +273,13 @@ def _compare_eq_iterable(
|
||||
if lines_left != lines_right:
|
||||
if lines_left > lines_right:
|
||||
max_width = min(len(x) for x in left_formatting)
|
||||
right_formatting = pprint.pformat(right, width=max_width).splitlines()
|
||||
lines_right = len(right_formatting)
|
||||
else:
|
||||
max_width = min(len(x) for x in right_formatting)
|
||||
left_formatting = pprint.pformat(left, width=max_width).splitlines()
|
||||
lines_left = len(left_formatting)
|
||||
|
||||
right_formatting = pprint.pformat(right, width=max_width).splitlines()
|
||||
lines_right = len(right_formatting)
|
||||
left_formatting = pprint.pformat(left, width=max_width).splitlines()
|
||||
lines_left = len(left_formatting)
|
||||
|
||||
if lines_left > 1 or lines_right > 1:
|
||||
_surrounding_parens_on_own_lines(left_formatting)
|
||||
|
||||
Reference in New Issue
Block a user