Skip to content

test: pin that zero and negative draw sizes paint nothing - #59

Merged
dmccoystephenson merged 3 commits into
mainfrom
test/pin-degenerate-draw-sizes
Oct 30, 2026
Merged

dmccoystephenson merged 3 commits into
mainfrom
test/pin-degenerate-draw-sizes

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle: the behavior of the draw methods at zero and negative sizes was unpinned, and one piece of it was undocumented.

  • Zero size — drawRectangle, drawImage and drawButton are pinned to draw no shape and raise nothing when width or height is 0. Layout-derived sizes (an empty bar, a list with no rows) reach zero routinely.
  • Negative size — drawRectangle and drawButton are pinned to draw no shape: the extent is not mirrored back from (xpos, ypos) into a normal rectangle. A mutant that normalizes the rect was confirmed to fail 6 of these tests.
  • drawImage negative size raises ValueError (from pygame.transform.scale). That behavior was undocumented; it is now pinned by a test and added to the drawImage docstring's Raises: section and the README.
  • drawButton at a degenerate size — pinned to have no clickable coordinate, including at its anchor and in the mirrored region. This is consistent with the documented "clickable region is exactly the drawn box". A non-empty label is still painted (only the box is skipped); this is pinned too, and the README wording says "draws no shape" rather than "draws nothing" for that reason.

No production behavior was changed. The graphik.py edit is docstring-only.

Test plan

  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py
  • python3 -m pytest (headless via conftest.py): 111 passed, 29 of them new. Run locally on Python 3.8.10 with pygame 2.1.2.
  • Mutation check: rewriting drawRectangle to normalize negative rects fails 6 negative-size tests; restoring the original passes them all.
  • CI 3.10, 3.11, 3.12 and 3.13: green.
  • CI 3.9: UNVERIFIED. The job fails in actions/setup-python before any project code runs, because ubuntu-latest now resolves to Ubuntu 26.04, which has no 3.9 build. The last green main run used ubuntu-24.04. This is environmental and is tracked in ci: the Python 3.9 test job fails at setup-python since ubuntu-latest moved to Ubuntu 26.04 #60.

Backlog skip reasons

No tracking issue — gap found during triage. The four open issues were left untouched because each is human-gated:

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

drawRectangle, drawButton and drawImage all paint nothing for a zero
width or height; drawRectangle and drawButton also paint nothing for a
negative one (it is not mirrored into a normal rectangle), and a button
sized either way has no clickable coordinate. drawImage instead raises
ValueError on a negative size, which its docstring and the README did
not mention -- document it alongside the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The box is skipped at a zero or negative size, but the label is drawn
by drawText regardless, so "draws nothing" was wrong for a button with a
non-empty label. Say "draws no shape" instead and pin the label case.

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

Copy link
Copy Markdown
Member Author

Self-review rubric (head 026e77b):

  • Scope: PASS — three files touched: the test module, one Raises: entry in the drawImage docstring, and one README paragraph. All of them pin or document zero/negative draw sizes.
  • Tests-new: PASS (n/a) — no new public method. 29 new characterization tests were added.
  • Tests-fix: n/a — no production fix. A mutation check stands in for it: rewriting drawRectangle to normalize negative rects failed 6 negative-size tests, and restoring the original passed them all.
  • Sibling structure: PASS — the new _draw_*_sized(graphik, imagePath, width, height) helpers and parametrize layout mirror the existing _draw_*_at helpers and the edge-clipping test next to them.
  • Sibling renames: n/a — nothing was renamed.
  • Docs: FAIL → fixed in 026e77b. The first README wording said a degenerate drawButton "draws nothing", but drawText still paints a non-empty label. The wording is now "draws no shape", and test_draw_button_with_a_degenerate_size_still_paints_its_label pins the label case.
  • Issue resolution: n/a — no Closes. The gap was found during triage.
  • Manual validation: PARTIAL. Local py_compile + import + pytest gave 111 passed (Python 3.8.10, pygame 2.1.2). CI 3.10–3.13 is green. CI 3.9 is UNVERIFIED: it fails in actions/setup-python (The version '3.9' with architecture 'x64' was not found for Ubuntu 26.04) before any project code runs. The last green main run used ubuntu-24.04. Rerunning main's 3.9 job to reproduce the failure there was not possible from this session. Tracked in ci: the Python 3.9 test job fails at setup-python since ubuntu-latest moved to Ubuntu 26.04 #60.
  • camelCase: PASS — no new public members. Test-local variables use imagePath, matching the neighbouring tests.
  • Backward-compat: PASS — no public signature or behavior changed. The graphik.py diff is docstring-only.
  • Headless: PASS — every new test uses _make_graphik or the shared conftest dummy drivers.
  • Version sync: n/a — _version.py is untouched.
  • No new deps: PASS — no new imports.

Out-of-diff observation: the class docstring's clipping paragraph does not mention degenerate sizes. The README now covers them, and the class docstring was left alone to keep the diff small.

Merge readiness: no do-not-auto-merge path is touched. Because this PR changes test files and the 3.9 slot is UNVERIFIED, it is held for a maintainer rather than auto-merged. Once #60 is resolved (or the maintainer accepts the 3.10–3.13 evidence, plus the local 3.8 run below the floor), it is ready to merge.

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


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson

Copy link
Copy Markdown
Member Author

Re-validation on head 026e77b (carried over from the previous cycle; the self-review above was confirmed already posted, so the rubric was not re-run):

  • Branch is current with main (2c148cf is an ancestor of the head); GitHub reports it mergeable.
  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py: OK.
  • python3 -m pytest (headless via conftest.py): 111 passed, 0 failed, on Python 3.8.10.
  • CI 3.10–3.13: green.
  • CI 3.9: still UNVERIFIED. It fails in actions/setup-python on Ubuntu 26.04 before any project code runs (ci: the Python 3.9 test job fails at setup-python since ubuntu-latest moved to Ubuntu 26.04 #60). A rerun of main's last 3.9 job, to reproduce the failure there, was not permitted from this session. The diff adds tests that the 3.9 job would execute, so the job cannot be classified as carrying no signal for this PR.

Merge decision: held again. The PR changes test files, so the unverified 3.9 slot falls under the anchor-relevant scope gate and auto-merge is not taken. Merging is unblocked once #60 is resolved (pin the runner, drop 3.9, or pin only the 3.9 slot), or once a maintainer accepts the 3.8-local + 3.10–3.13 CI evidence as sufficient.

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


drafted by Claude on behalf of Daniel Stephenson

ubuntu-latest now resolves to Ubuntu 26.04, for which setup-python
publishes no 3.9 build, so the 3.9 job failed before running anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson
dmccoystephenson merged commit e97db66 into main Oct 30, 2026
5 checks 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.

1 participant