Skip to content

test: pin that drawText renders one line and rejects a null character - #71

Merged
dmccoystephenson merged 1 commit into
mainfrom
test/pin-draw-text-single-line-and-null-character
Nov 11, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
test/pin-draw-text-single-line-and-null-character

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle on drawText's text argument. Two behaviors were found to be neither tested nor documented, and are now pinned as characterization tests and described in the docs:

  • Newlines are not line breaks. drawText renders its text as a single line; a "\n" is drawn inline (as a glyph) rather than starting a new line, so multi-line text needs one call per line. test_draw_text_does_not_break_lines_at_a_newline asserts the ink of "A\nB" fits within one font line height.
  • A null character raises. pygame refuses to render text containing "\0", and the ValueError reaches the caller before anything is blitted. test_draw_text_with_a_null_character_raises_value_error_and_paints_nothing pins both halves.
  • The drawText docstring (text arg) and the README's drawText bullet were updated to describe both.

No production behavior was changed — only a docstring line in graphik.py. The public API is untouched (no consumer-impact check needed).

Test plan

  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py
  • pytest — 153 passed (151 before + 2 new), headless via the existing conftest dummy SDL drivers
  • Behavior verified empirically on pygame 2.1.2 before writing the tests (Font.size("a\nb") has the single-line height of "ab"; render("a\0b") raises ValueError: A null character was found in the text)

Skipped issues

All open issues were deferred this cycle, each pending a maintainer decision:

No tracking issue — gap found during a test-coverage sweep.

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

A "\n" in drawText's text is not a line break, and a "\0" raises
ValueError from pygame before anything is painted. Neither was
documented or tested; both are now pinned and described in the
drawText docstring and the README.

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

Copy link
Copy Markdown
Member Author

Self-review rubric (posted as a plain comment; no independent reviewer was configured — --add-reviewer Copilot could not be resolved):

  • Scope: PASS — three files: the two new tests, the text arg line of the drawText docstring, and the README drawText bullet. No unrelated churn.
  • Tests-new: PASS (n/a) — no new public method was added.
  • Tests-fix: n/a — characterization-only; no production behavior was changed, so there is no fix to stash-and-revert.
  • Sibling structure: PASS — the tests sit beside test_draw_text_accepts_an_empty_string_and_paints_nothing and follow its _make_graphik / fill / _rgb scan pattern.
  • Sibling renames: n/a — nothing renamed.
  • Docs: PASS — docstring and README describe both pinned behaviors; pyproject.toml (version/deps) is unaffected.
  • Issue resolution: n/a — no Closes; a gap found during a coverage sweep.
  • Manual validation: PASS — py_compile OK; local pytest 153 passed on pygame 2.1.2; CI Compile and test green on 3.9–3.13 with pygame 2.6.1 (153 passed per job log).
  • camelCase: PASS — new locals (inkedRows, lineHeight) follow the file's camelCase style; no public API touched.
  • Backward-compat: PASS — no public member changed; consumer-impact gate not triggered.
  • Headless: PASS — tests rely on the existing conftest dummy SDL drivers.
  • Version sync: PASS (n/a) — no version string changed.
  • No new deps: PASS — no imports added.

Observations (judgment calls, not applied):

  • README.md:51 — drawButton's label is rendered through drawText, so a "\n" or "\0" in text behaves the same there; the drawButton bullet does not repeat this. It was left out on the grounds that the label is already documented as drawText-rendered, but a one-clause cross-reference could be added if preferred.
  • src/test/python/preponderous/graphik/test_graphik.py:720 — the newline test's discrimination was established by reasoning (two lines would span at least one line height plus a cap height, exceeding get_linesize()) rather than by an alternative implementation; the behavior itself was confirmed empirically on pygame 2.1.2 (Font.size("a\nb") has the height of "ab").
  • Out of diff: drawText(None, ...) renders nothing rather than raising on pygame 2.1.2, and bytes text is accepted. Neither was pinned, to keep this PR to one cohesive behavior pair.

Verdict: ready to merge — test/doc-only, no do-not-auto-merge path touched, anchor green.

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 be6cb46 into main Nov 11, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the test/pin-draw-text-single-line-and-null-character branch November 11, 2026 06:40
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