Skip to content

Commit ccda3bb

Browse files
committed
dynamic truncation
1 parent 9ec5408 commit ccda3bb

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

check50/_api.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,14 @@ class Mismatch(Failure):
457457
def __init__(self, expected, actual, help=None):
458458
expected, actual = _truncate(expected, actual), _truncate(actual, expected)
459459

460-
rationale = _("expected {}, not {}").format(
461-
_raw(expected),
462-
_raw(actual)
463-
)
464-
# rationale = _("expected: {}\n actual: {}").format(
460+
# rationale = _("expected {}, not {}").format(
465461
# _raw(expected),
466462
# _raw(actual)
467463
# )
464+
rationale = _("expected: {}\n actual: {}").format(
465+
_raw(expected),
466+
_raw(actual)
467+
)
468468

469469
super().__init__(rationale=rationale, help=help)
470470

@@ -507,7 +507,11 @@ def wrapper(*args, **kwargs):
507507
return decorator
508508

509509
def _truncate(s, other, max_len=10):
510-
"""Truncate string s around its first difference with other"""
510+
511+
if isinstance(s, list):
512+
s = "\n".join(s)
513+
if isinstance(other, list):
514+
other = "\n".join(other)
511515

512516
# find the index of first difference
513517
limit = min(len(s), len(other))

0 commit comments

Comments
 (0)