fix(test): compare toast height against a one-word toast, not lineSpacing - #878
Merged
marcinz606 merged 1 commit intoAug 17, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_a_short_message_keeps_its_natural_widthbounds the toast height byfontMetrics().lineSpacing() * 2, but the height also carries what the stylesheet gives it._TOAST_QSSaddspadding: 7px 18pxand 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
LONGtoast, which is the more obvious reference but is weaker than what it replaces: mutatingsetMinimumWidth(min(cap, one_line))tosetMinimumWidth(0), which is the exact inflation this test exists to catch, folds both toasts together and that comparison passes at51 < 87. A one-word toast cannot wrap, so it still catches the mutant atassert 49 <= 31.Before:
pytest tests/test_altprocess_sidebar.py tests/test_hud_toast.pyfails here withassert 33 <= (16 * 2), whilepytest tests/test_hud_toast.pyalone 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.