Skip to content

test: pin text color, button label placement, star import, and per-path scale cache - #43

Merged
dmccoystephenson merged 1 commit into
mainfrom
test/pin-text-rendering-star-import-and-scaled-cache-scoping
Sep 20, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
test/pin-text-rendering-star-import-and-scaled-cache-scoping

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Test-only expansion (Stage B of the dev loop). Five characterization tests are added to src/test/python/preponderous/graphik/test_graphik.py for documented behaviors that were not previously pinned. No production code is changed.

  • drawText color — glyphs are painted with the requested color: on a black background a red "W" at size 40 produces at least one exactly-red pixel, and every inked pixel is a pure shade of red (no green/blue component from antialiasing against a different hue).
  • drawButton label placement — the label sits entirely inside the drawn box, straddles the box midpoint on both axes, and is horizontally centered on it to within 1px (the same tolerance the existing drawText centering test uses, for the same glyph-asymmetry reason).
  • drawButton label color — the label is rendered in colorText, not colorBox; a swap of the two arguments (which would make the label invisible against its own box) is caught.
  • Star import — from preponderous.graphik import * resolves Graphik through the package's lazy __getattr__ via __all__; a name listed in __all__ that __getattr__ could not serve would make the star import itself raise.
  • Scaled-image cache scoping — the (size, surface) pair is kept per filePath, so rescaling one asset leaves another asset's cached scale intact (red at 10→12 does not force blue at 10 to be rescaled).

Each new test was confirmed to fail under a targeted mutation of the behavior it pins (color swapped to white; label anchored at the top-left; colorBox passed to drawText; a single shared cache slot; Graphik dropped from __all__) and to pass on the real code.

Test plan

  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py
  • python3 -c "import preponderous.graphik as g; print(g.__version__)" (import smoke test)
  • python3 -m pytest -q → 52 passed (47 baseline + 5 new), headless via conftest.py's dummy SDL drivers
  • Mutation check: all 5 new tests fail when the pinned behavior is broken, pass when restored
  • CI Test workflow green across the 3.9–3.13 matrix

Triage notes

No tracking issue — gap found during triage. The three open issues were all deferred this cycle because each is explicitly maintainer-gated:

A documentation sweep (README, RELEASING.md, pyproject.toml, docstrings) found no drift against the current source, so test expansion was chosen as the work mode.

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

…th scale cache

Characterization tests only; no production change. Each new test was
confirmed to fail under a targeted mutation of the behavior it pins:

- drawText paints glyphs in the requested color (exact match on covered
  pixels, only blends of that color elsewhere).
- drawButton centers its label on the box midpoint and renders it in
  colorText, not colorBox.
- `from preponderous.graphik import *` resolves Graphik through the lazy
  __getattr__ via __all__.
- The scaled-image cache keeps one (size, surface) pair per path, so
  rescaling one asset does not evict another's entry.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (anchored on the green Test workflow, run 35496996740 — 52 passed on each of 3.9/3.10/3.11/3.12/3.13):

Observations outside the diff (not blocking): the two exact-color assertions assume a 24/32-bit display surface, which the existing exact-color tests in the file already assume, so no new fragility is introduced. Inline review (code-review skill, medium effort) reported no findings.

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 ae8678b into main Sep 20, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the test/pin-text-rendering-star-import-and-scaled-cache-scoping branch September 20, 2026 07:31
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