qa: assert_equals -> assert_true/assert_false

bitcoin/bitcoin: PR #36257

2 suggestions

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Optional improvements

Link

[suggestion] · assert_true and assert_false failures omit the received value

The new functional-test helpers lose the operand diagnostics provided by assert_equal, making unexpected non-boolean results harder to identify.

Location: test/functional/test_framework/util.py:91 (head).

Details and suggested fix

For example, wallet_address_types.py now calls assert_true(info.get('solvable')). If the key is missing, the old assertion reported not(None == True), while the new one reports only Expression was not True. The identity checks also reject other non-boolean values, which the fixed messages cannot distinguish. Include {expression!r} in both failure messages while retaining the identity checks. This improves diagnostics without changing the exact-boolean requirement, AssertionError type, or behavior under python -O.


Link

[suggestion] · Unrelated import formatting obscures the manual preparation patch

The manual import commit mixes required additions with existing-import reordering and reindentation, making it harder to check which names the scripted conversion needs.

Location: test/functional/rpc_blockchain.py:58 at 4e7ce4d9c1a7 (commit) (commit).

Details and suggested fix

In 4e7ce4d9c1a7cb441285c0f1d9ddc1c8d7b4782c (inspected with parent=null), rpc_blockchain.py gains assert_true but also reorders three existing imports; wallet_reorgsrestore.py reindents the whole import block. Drop those unrelated formatting edits so the manual patch contains only the additions needed by the scripted conversion in 9bdc0f9d058fee75184e02e5db4ad0f7fe5a1a72. Keep the necessary imports before that conversion and retain the unused-assert_equal cleanup in 772a560fa05a1fa801a85541d2179f840ef85490. This preserves runtime name availability while reducing the lines reviewers must reconcile manually. This is a review-flow suggestion, not a final-tree defect.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

The author's stated benefit was readability: putting the expected boolean at the beginning avoids searching past a long condition. l0rinc questioned the additional value over assert_equal(True, ...) and requested a separate helper proposal with a scripted conversion so its readability could be evaluated independently of the dormant-check repair.

This directly explains why the earlier small helper demonstration was separated from its motivating fix. It also distinguishes the naming/readability objective from changing which result types assertions accept.

Source 1 · Source 2 · Source 3

Unresolved disagreements

The inspected discussion did not resolve whether built-in assert should be reserved for internal test sanity checks or whether optimized functional-test execution should instead be rejected at startup. The author cited value in that distinction; maflcko questioned its usefulness in developer-only test scripts. Removing the helper deferred rather than settled that disagreement.

This limits how strongly the earlier withdrawal can be interpreted as a decision about assertion semantics or compatibility. Its explicit unresolved tradeoff concerned assertion policy and optimized execution.

Source 1 · Source 2 · Source 3 · Source 4