Skip to content

fix(test): compare toast height against a one-word toast, not lineSpacing - #878

Merged
marcinz606 merged 1 commit into
marcinz606:mainfrom
MohammedAlkindi:fix/hud-toast-height-assertion
Aug 17, 2026
Merged

fix(test): compare toast height against a one-word toast, not lineSpacing#878
marcinz606 merged 1 commit into
marcinz606:mainfrom
MohammedAlkindi:fix/hud-toast-height-assertion

Conversation

@MohammedAlkindi

Copy link
Copy Markdown
Contributor

test_a_short_message_keeps_its_natural_width bounds the toast height by fontMetrics().lineSpacing() * 2, but the height also carries what the stylesheet gives it. _TOAST_QSS adds padding: 7px 18px and a 1px border, so 16px vertical that the font metric knows nothing about.

That makes the bound sensitive to font registration order. Without qtawesome's icon fonts, lineSpacing is 18, the one-line label is 31 and the bound is 36. With them registered, lineSpacing drops to 16 while the label grows to 33, so the bound falls to 32 and the assertion fails. The file passes alone and fails after any test that pulls qtawesome in.

This is the thirteenth item from #835, the one left undiagnosed there as "order-dependent Qt state, listed for completeness". #840 fixed the twelve deterministic failures and did not scope this one.

The fix compares the short toast against a one-word toast measured the same way instead of against a font metric. I did not compare it against the wrapped LONG toast, which is the more obvious reference but is weaker than what it replaces: mutating setMinimumWidth(min(cap, one_line)) to setMinimumWidth(0), which is the exact inflation this test exists to catch, folds both toasts together and that comparison passes at 51 < 87. A one-word toast cannot wrap, so it still catches the mutant at assert 49 <= 31.

Before: pytest tests/test_altprocess_sidebar.py tests/test_hud_toast.py fails here with assert 33 <= (16 * 2), while pytest tests/test_hud_toast.py alone passes. After: both orders pass. Full suite on the branch is 4231 passed, 9 skipped, 11 deselected, 0 failed.

I could only run this on Windows, so the numbers above are from that machine and CI is the authority for Linux.

test_a_short_message_keeps_its_natural_width bounded the toast's height
by fontMetrics().lineSpacing() * 2, but a label's height is not a
multiple of a font metric. _TOAST_QSS gives the toast 7px of padding
above and below plus a 1px border, so 16px of every toast is chrome
that no font metric scales with.

lineSpacing() moves with what the Qt font database holds. Measured on
this checkout, under the offscreen platform conftest selects: with only
the HUD imported the label is 31px against a bound of 36; once an
earlier module has registered qtawesome's icon fonts, lineSpacing()
resolves to 16, so the label is 33px against a bound of 32. That is the
order dependence, and it is why the file passes on its own and fails
after tests/test_altprocess_sidebar.py.

The toast renders correctly either way, so the assertion is what moves.
It now measures the same label showing a single word, which cannot
wrap, and requires the short message to be no taller. Both heights
carry the same padding and border, and neither reads a font metric.
The check still fails if the width floor stops keeping a short message
on one line, which is what it is there to catch.

Refs marcinz606#835.
@marcinz606
marcinz606 merged commit 45860a6 into marcinz606:main Aug 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants