Skip to content

test: pin that draw methods render to the bound surface, not the display - #48

Merged
dmccoystephenson merged 2 commits into
mainfrom
test/pin-draws-target-bound-surface
Oct 2, 2026
Merged

dmccoystephenson merged 2 commits into
mainfrom
test/pin-draws-target-bound-surface

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle: no production code is changed.

  • The Graphik class docstring states that every draw method "renders to the surface the instance was constructed with". Every existing test binds Graphik to the display surface itself, so nothing distinguished drawing to the bound surface from drawing to pygame.display.get_surface().
  • A parametrized test, test_draw_methods_render_to_the_bound_surface_not_the_display, is added. It binds Graphik to an off-screen pygame.Surface and runs each of drawRectangle, drawText, drawButton and drawImage. It then requires that the bound surface was drawn to and the display was left untouched.
  • This matters to consumers that draw into an off-screen buffer rather than straight to the window.

No tracking issue: the gap was found during triage by comparing the class docstring with the existing tests.

Evidence the test pins real behavior

The three draw targets in graphik.py (pygame.draw.rect(self.gameDisplay, …) and both self.gameDisplay.blit(…) calls) were temporarily replaced with pygame.display.get_surface():

  • all 4 new parametrized cases failed;
  • 53 of the 54 existing tests still passed, which confirms the gap was real;
  • with the source restored, the full suite passed (58 tests).

Test plan

  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py
  • Import smoke test: from preponderous.graphik import Graphik
  • python3 -m pytest: 58 passed, run headless through conftest.py's dummy SDL drivers
  • Mutation check described above (FAIL with the mutation, PASS without it)

Deferred issues (skip reasons)

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

dmccoystephenson and others added 2 commits October 2, 2026 02:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (Graphik dev loop, Phase 4), scored against the diff and command output:

  • Scope: PASS. One file changes (src/test/python/preponderous/graphik/test_graphik.py, +50 lines). Production code is untouched, as a Stage B cycle requires.
  • Tests-new: PASS (n/a). No new public method is added.
  • Tests-fix (empirical): PASS. Characterization rather than a fix. With the three draw targets in graphik.py temporarily pointed at pygame.display.get_surface(), all 4 new cases failed. With the source restored, all 58 tests passed.
  • Sibling structure: PASS. The test sits beside the other cross-method test (test_caches_belong_to_the_instance_not_the_class) and reuses the existing _write_solid_image and _rgb helpers. It follows the file's pytest.param(..., id=...) style and camelCase locals.
  • Sibling renames: PASS (n/a). Nothing is renamed.
  • Docs: PASS. No behavior changes, so README, RELEASING.md and the docstrings need no update. The test enforces the existing class-docstring claim.
  • Issue resolution: PASS (n/a). There is no Closes #N, and the body says the gap was found during triage.
  • Manual validation: PASS. Locally, py_compile, the import smoke test and pytest (58 passed) are green. The Test workflow is green on 3.9–3.13 for head 5966298 (run 36985776296).
  • camelCase: PASS (n/a). No public method is added.
  • Backward-compat: PASS. No public member is touched.
  • Headless: PASS. The test runs under conftest.py's dummy SDL drivers and uses an off-screen pygame.Surface.
  • Version sync: PASS (n/a). _version.py is untouched.
  • No new deps: PASS. No new imports.

Finding raised and fixed during review:

  • src/test/python/preponderous/graphik/test_graphik.py:670: the first draft of the comment said a wrong draw target "would pass all" other tests. Under the mutation, test_draw_text_drops_cached_font_when_the_display_session_changes also failed, but only incidentally: it expects a pygame.error from the stale display, and the mutation no longer raises one. The comment was reworded to say exactly that in 5966298.

Do-not-auto-merge check: there are no workflow, security/, or LICENSE paths, and no file has more than 50 deleted lines.

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 e631e34 into main Oct 2, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the test/pin-draws-target-bound-surface branch October 2, 2026 08:45
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