qa: Avoid duplicating output in case the diff is the same
What changed, and why it matters
This is a tiny quality-of-life improvement to Bitcoin Core's internal Python test framework. It stops an error message from printing the same dictionary twice when a test assertion fails. It does not change any production Bitcoin code, network behavior, or security logic.
No security action needed. Treat as normal test-framework maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/functional/test_framework/util.py’s assert_equal helper. When comparing two dicts that are not equal, the code previously always printed both the full dicts and a summary diff. Now, if the summary diff is identical to the full dicts, it omits the redundant ‘in particular’ line. This is purely a test-output formatting change; the assertion still fires and the test still fails.
Changed components
test/functional/test_framework/util.pyInspect captured patch +4 / −1
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index 03ece6f0..d6378e88 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -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))
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.