Skip to content

test: pin drawImage's exact drawn region and its missing-file error type - #47

Merged
dmccoystephenson merged 1 commit into
mainfrom
test/pin-draw-image-failure-and-anchor
Sep 30, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
test/pin-draw-image-failure-and-anchor

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle targeting drawImage. No production code is changed.

  • New test test_draw_image_fills_exactly_the_requested_region. Every existing drawImage test scales to a square size (10x10, 12x12) or a single-pixel-high one (2x1), so nothing distinguished width from height. A mutant scaling to (height, width) was confirmed to pass all 53 existing tests. The new test draws a non-square 6x5 region at offset (3, 4) and pins every corner plus the first pixel past each edge. That also pins the documented top-left anchoring to the pixel, mirroring test_draw_rectangle_fills_exactly_the_requested_region.
  • Tightened missing-file assertions. test_draw_image_missing_file_raises (renamed ..._raises_file_not_found_error) and test_draw_image_does_not_cache_a_failed_load accepted (FileNotFoundError, pygame.error). The drawImage docstring promises FileNotFoundError for a missing path and reserves pygame.error for undecodable files, so both now assert FileNotFoundError only. It was confirmed empirically that pygame.image.load raises FileNotFoundError for a missing .bmp or .png path. The comment on the neighboring undecodable-file test, which described the old loose assertion, was updated to match.

No tracking issue. The gap was found during triage.

Mutation evidence

Mutant in graphik.py (reverted after each run) Existing tests New test
size = (height, width) all pass fails
blit at (xpos + 1, ypos) 1 fails (transparent-pixel test) fails
center-anchored blit 4 fail fails

Test plan

  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py
  • Import smoke test (import preponderous.graphik) prints 0.3.0.dev20260808
  • python3 -m pytest: 54 passed, run locally on Python 3.8 / pygame 2.1.2 with the conftest's dummy SDL drivers
  • CI Test workflow green across 3.9–3.13 (this also confirms that the newer pygame wheels raise FileNotFoundError too)

Triage notes (skipped issues)

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


drafted by Claude on behalf of Daniel Stephenson

🤖 Generated with Claude Code

Scaling to (height, width) instead of (width, height) passed every
existing drawImage test, since all of them use square or single-pixel-high
sizes. A non-square region drawn at an offset now pins both dimensions and
the top-left anchoring to the pixel.

The missing-file tests accepted FileNotFoundError or pygame.error, while
the docstring promises FileNotFoundError specifically and reserves
pygame.error for undecodable files. Both are tightened to the documented
type.

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

Copy link
Copy Markdown
Member Author

Self-review rubric (performed inline in the same session, so it is not independent review):

  • Scope: PASS. Only src/test/python/preponderous/graphik/test_graphik.py is modified (+36/−6), and every hunk belongs to one of the two drawImage characterizations described in the PR body.
  • Tests-new: N/A. No new public method was added.
  • Tests-fix: N/A. This is a characterization-only change with no production fix. Mutation runs stand in for it: a (height, width) scale mutant survived all 53 pre-existing tests and was caught only by the new test. Off-by-one and center-anchor blit mutants were also caught. Every mutant was reverted with git checkout --, and the final tree has no change under src/main.
  • Sibling structure: PASS. The new test follows test_draw_rectangle_fills_exactly_the_requested_region (corner and edge-plus-one assertions, _make_graphik, _rgb, and _write_solid_image helpers).
  • Sibling renames: PASS. test_draw_image_missing_file_raises was renamed to match its sibling test_draw_image_undecodable_file_raises_pygame_error, and the only prose that referenced the old loose assertion (the undecodable-file test's comment) was updated in the same commit.
  • Docs: PASS. No documented behavior changed. The drawImage docstring's Raises: section is now what the tests assert, and the README makes no exception-type claim.
  • Issue resolution: N/A. There is no Closes #N, and the gap was found during triage.
  • Manual validation: PASS. Locally, py_compile, the import smoke test, and pytest (54 passed) all succeeded. The CI Test workflow passed on 3.9, 3.10, 3.11, 3.12, and 3.13, which also confirms that current pygame wheels raise FileNotFoundError for a missing path.
  • camelCase / Backward-compat / Version sync / No new deps: PASS. No change was made to graphik.py, the public surface, version sources, or imports.
  • Headless: PASS. The new test uses _make_graphik under the conftest's dummy SDL drivers.

Findings:

  • src/test/python/preponderous/graphik/test_graphik.py:131 — nit: the comment's "scaling to (height, width) instead passes all of them" is true against today's suite, but it will go stale if a later non-square test is added. This is acceptable because it records why the test exists, and was left as-is.
  • src/test/python/preponderous/graphik/test_graphik.py:164 — tightening to FileNotFoundError relies on pygame's missing-file behavior. That behavior was verified locally on pygame 2.1.2 and in CI on the current wheels, so the tighter assertion now also acts as an early warning if a pygame release changes it.

The PR is ready to merge. It contains test-only changes, no do-not-auto-merge path is touched, and CI is green.

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


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit fe8c052 into main Sep 30, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the test/pin-draw-image-failure-and-anchor branch September 30, 2026 09:46
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