qa: Avoid duplicating output in case the diff is the same

This commit is contained in:
Hodlinator 2026-01-26 16:25:59 +01:00
parent c2e28d455a
commit 111864ac30
No known key found for this signature in database

View File

@ -75,7 +75,10 @@ def summarise_dict_differences(thing1, thing2):
def assert_equal(thing1, thing2, *args):
if thing1 != thing2 and not args and isinstance(thing1, dict) and isinstance(thing2, dict):
d1,d2 = summarise_dict_differences(thing1, thing2)
raise AssertionError("not(%s == %s)\n in particular not(%s == %s)" % (thing1, thing2, d1, d2))
if d1 != thing1 or d2 != thing2:
raise AssertionError(f"not({thing1!s} == {thing2!s})\n in particular not({d1!s} == {d2!s})")
else:
raise AssertionError(f"not({thing1!s} == {thing2!s})")
if thing1 != thing2 or any(thing1 != arg for arg in args):
raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))