test: pin drawImage failure modes, button-1 gating, and per-instance caches - #42
Conversation
…caches Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Self-review rubricScored against the diff and against command output, not judgement. The external
Findings1. The cache-isolation test was initially blind to partial sharing (fixed in 2. The missing-path exception type is still asserted loosely (left as is). 3. Mouse state is asserted as 3-tuples. This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Summary
Four behaviors that the
Graphikdocstrings promise, or that the cache designdepends on, were not exercised by any test. They are pinned here as
characterization tests. No production code is changed — the source diff is
empty and only
test_graphik.pyis touched.drawImagedistinguishes its two failure modes. The docstring'sRaises:section separates
FileNotFoundError(no file at the path) frompygame.error(a file that exists but cannot be decoded). Only the first wasreachable by a test, and that test accepts either type, so nothing pinned the
second. A text file named
.bmpis now asserted to raisepygame.errorspecifically.
to load "caches nothing and raises on every call". The existing test only
observed the first raise. The load is now asserted to be re-attempted on each
of three consecutive failures, and an asset that appears on disk afterwards is
asserted to draw on the very next call — which is the user-visible consequence
of not negative-caching.
drawButtongates on button 1 specifically. The parametrized hit-test caselist covered "pressed" and "not pressed" but no press of a different button.
Three cases are added: middle-only and right-only must not fire the callback,
while button 1 held together with the others must.
_fontsand_imagesare built in
__init__, so twoGraphikobjects cannot serve each otherstale entries — and for the font cache that isolation is what keeps
_getFont'sdisplay-session check meaningful. The isolation is pinned on observable work
(one font construction and one image load per instance) rather than on the
private dictionaries.
Evidence each test bites
Every addition was confirmed empirically by temporarily mutating the source,
running the suite, and restoring it:
graphik.pytest_draw_image_undecodable_file_raises_pygame_errorNoneand re-raised from the cachetest_draw_image_does_not_cache_a_failed_loadif click[0] == 1widened toif any(click)..._invokes_callback_only_on_inside_click[middle_button_only],[right_button_only]_imagesmoved to a class attributetest_caches_belong_to_the_instance_not_the_class(image half)_fontsand_fontDisplaymoved to class attributestest_caches_belong_to_the_instance_not_the_class(font half)Both halves of the isolation assertion were mutated separately, so neither is
carried by the other. The working tree was verified clean after each revert.
Deferred issues
The three open issues were all skipped this cycle. Each reason is recorded here
rather than as a comment on the issue itself:
vprefix) — the issue presents twomutually exclusive directions and states explicitly that the choice is a
maintainer decision. It also touches
.github/workflows/and the releaseprocess, both excluded from autonomous change.
workflow file, which the issue itself records as excluded from autonomous
change.
preponderous/__init__.pyshipping a regular package) — thestated prerequisite, which convention the sibling Preponderous-Software Python
projects follow, cannot be settled from inside this repository.
With the backlog entirely maintainer-gated, this cycle was spent on test
expansion instead.
Test plan
python3 -m py_compile src/main/python/preponderous/graphik/graphik.py— succeedspython3 -m pytest— 47 passed (41 before this change)conftest.pydummy SDL drivers cover them
against the restored one (table above)
No tracking issue — this is a test-expansion cycle, not an issue fix.
This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson