Skip to content

test: pin that drawImage caches by the path exactly as given - #72

Merged
dmccoystephenson merged 1 commit into
mainfrom
test/pin-draw-image-cache-key
Nov 12, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
test/pin-draw-image-cache-key

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle for drawImage's cache key. No production behavior is changed; the only edits to graphik.py are to its docstring.

  • Every existing drawImage test passed str(path), so what the cache does with any other kind of filePath was unguarded.
  • test_draw_image_accepts_a_pathlib_path_and_caches_it pins that a pathlib.Path is accepted, draws correctly, and that a fresh but equal Path is served from the cache (one load).
  • test_draw_image_caches_by_the_path_as_given_not_the_file_it_names pins that the key is the argument exactly as given, with no normalization: str(abs), Path(abs), "red.bmp" and "./red.bmp" naming one file are four entries, each loaded once and then cached.
  • The drawImage docstring and the README drawImage bullet now state both facts.

Mutation check: with filePath = str(filePath) inserted ahead of the cache lookup, both new tests fail. With it removed again, both pass.

Skipped issues

Every open issue was deferred because each needs a maintainer decision or touches a path excluded from autonomous change:

Test plan

  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py
  • pytest: 155 passed (153 before, plus 2 new), under the dummy SDL driver configured in conftest.py
  • Mutation check described above (FAIL with the key normalized, PASS without it)

No tracking issue: this gap was 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

Every drawImage test passed str(path), leaving the cache-key semantics
unguarded: a pathlib.Path is accepted and hits the cache for an equal
Path, while different spellings of one file are separate entries. Pin
both and document them in the docstring and README.

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

Copy link
Copy Markdown
Member Author

Self-review rubric (performed inline in a headless dispatch; this is not an independent review):

  • Scope: PASS. Three files changed: two characterization tests, plus a matching sentence in the drawImage docstring and the README bullet. No production logic changed (git diff origin/main...HEAD -- graphik.py touches only the docstring).
  • Tests-new: PASS (not applicable). No new public method was added.
  • Tests-fix: not applicable (no bug fix). In its place, a mutation check was run: inserting filePath = str(filePath) ahead of the cache lookup made both new tests fail, and removing it made them pass.
  • Sibling structure: PASS. The tests reuse _make_graphik, _write_solid_image, _count_image_loads and _rgb, follow the existing test_draw_image_* naming and lead-comment style, and sit next to test_draw_image_caches_each_path_independently.
  • Sibling renames: PASS (not applicable). Nothing was renamed.
  • Docs: PASS. The docstring Args: entry and the README drawImage bullet both describe the pinned key semantics. version.txt and pom.xml no longer exist; _version.py is unchanged.
  • Issue resolution: PASS (not applicable). There is no Closes. The gap was found during triage.
  • Manual validation: PASS. py_compile is clean, the local pytest run passed 155 tests (153 plus 2 new) on pygame 2.1.2, and CI Compile and test passed on 3.9, 3.10, 3.11, 3.12 and 3.13 against current pygame.
  • camelCase / Backward-compat / No new deps: PASS. No public surface or import changed.
  • Headless: PASS. The tests run under the dummy SDL driver from conftest.py.

Findings:

  • src/test/python/preponderous/graphik/test_graphik.py:416: assert loaded == [(image_path,)] also pins that drawImage calls pygame.image.load with a single positional argument. A harmless refactor (for example, passing a namehint) would make this assertion fail. This is accepted as minor, because the sibling test_draw_image_caches_each_path_independently already depends on args[0] in the same way.
  • README.md:52: the "str or pathlib.Path" claim was confirmed on pygame 2.1.2 locally and on the current pygame in CI. Older pygame 1.9 is out of scope because requires-python>=3.9.

No blocking items. The PR 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
dmccoystephenson merged commit 72b631a into main Nov 12, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the test/pin-draw-image-cache-key branch November 12, 2026 06:01
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