Skip to content

test: pin drawText and drawButton behavior for an empty label - #54

Merged
dmccoystephenson merged 1 commit into
mainfrom
test/pin-empty-text-labels
Oct 19, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
test/pin-empty-text-labels

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle for the text-rendering paths of Graphik.

  • drawText("") and drawButton(..., text="", ...) had no coverage. pygame renders an empty string to a zero-width surface, so today drawText paints nothing and drawButton draws a plain box that is still clickable. Two characterization tests now pin that:
    • test_draw_text_accepts_an_empty_string_and_paints_nothing — draws onto a green surface and requires every pixel to stay green.
    • test_draw_button_with_an_empty_label_draws_a_plain_box — requires the whole box to be colorBox, no label ink, and the callback to still fire on an inside click.
  • A regression these would catch: raising on "", or substituting placeholder text (e.g. text or " " rendered with an opaque background).
  • Test-only change; graphik.py is untouched, and no public API changes, so no consumer-impact check is needed.

Skipped issues

All open issues were deferred because each needs a maintainer decision or touches a path excluded from autonomous change:

A Stage A documentation sweep (README, RELEASING.md, pyproject, docstrings) was run first. It found no drift that is not already tracked in #39/#46.

Test plan

  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py
  • python3 -m pytest -rA (headless via conftest): 66 passed (was 64), and both new tests are listed as PASSED
  • CI Test workflow green on 3.9–3.13

No tracking issue — gap found during triage.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

An empty string renders to a zero-width surface, so drawText paints
nothing and drawButton draws a plain, still-clickable box. Nothing
covered this, so a change that raised on "" or substituted placeholder
text would have gone unnoticed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (one intrinsic pass, anchored on CI and local commands):

  • Scope: PASS — the diff touches only src/test/python/preponderous/graphik/test_graphik.py (+31 lines), and nothing else.
  • Tests-new: PASS (n/a) — no new public method was added. Two characterization tests were added.
  • Tests-fix: n/a — this is not a bug fix. A mutation check was run instead: changing drawText to myFont.render(text or " ", True, color, (1, 2, 3)) made both new tests FAIL (2 failed). Restoring graphik.py with git checkout -- made them PASS again (2 passed). So the tests can detect the regression the PR body names.
  • Sibling structure: PASS — each test is placed next to its siblings (after the other drawText surface tests and after the drawButton label tests). Both reuse the existing _make_graphik, _rgb and _button_label_ink helpers and the same monkeypatched pygame.mouse pattern.
  • Sibling renames: n/a — nothing was renamed.
  • Docs: PASS — no behavior changed, so README, RELEASING.md and the docstrings stay accurate. A Stage A sweep of those files found no new drift; the drift that exists is already tracked in ci: test.yml's header comment claims it runs on every push, but pushes outside main are only covered via pull_request #39 and release: publish.yml's wheel smoke test never imports Graphik, so a wheel missing graphik.py would still publish #46.
  • Issue resolution: n/a — no Closes reference. The PR body records it as a gap found during triage.
  • Manual validation: PASS — py_compile succeeded, and the local pytest -rA run gave 66 passed (was 64), with both new tests listed. CI Compile and test passed on 3.9, 3.10, 3.11, 3.12 and 3.13.
  • camelCase: n/a — no public method was added or renamed.
  • Backward-compat: PASS — graphik.py is unchanged on the PR head.
  • Headless: PASS — both tests run under the conftest dummy SDL drivers, and the mouse state is monkeypatched.
  • Version sync: n/a — no version string changed.
  • No new deps: PASS — no new imports.

Judgment call flagged: src/test/python/preponderous/graphik/test_graphik.py — the empty-string behavior depends on pygame ≥ 2 returning a zero-width surface (old pygame 1.9 raised "Text has zero width"). The pygame dependency is unpinned, so these tests also guard against that older behavior coming back in the supported environment. This is intended, not a defect.

Result: ready to merge. Only a test file changed, and none of the do-not-auto-merge paths are touched.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 544fd31 into main Oct 19, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the test/pin-empty-text-labels branch October 19, 2026 12:16
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.

1 participant