Skip to content

Add test coverage for FishE.play() and error-recovery paths - #130

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/expand-fishE-play-loop-tests
Jul 28, 2026
Merged

Add test coverage for FishE.play() and error-recovery paths#130
dmccoystephenson merged 1 commit into
mainfrom
feature/expand-fishE-play-loop-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • src/fishE.py's core game loop (play()) had zero test coverage — every line inside it (location transitions, milestone announcements, eviction messages, goal announcement, per-tick save) was unexercised.
  • Added coverage for loadStats/loadTimeService corrupt-file recovery, save()'s missing-data-directory creation and write-failure handling, and the __init__ path that loads timeService.json when present (previously only the "file absent" branches were tested).
  • Coverage-only change: no production code modified. src/fishE.py line coverage goes from 77% to 99% (the remaining 2 lines are the if __name__ == "__main__": entry point, which isn't unit-testable).

Full backlog note: the repo's one open issue (#122, whether the stale PLANNING.md GOALS bait-price note should be deleted) requires the repo owner's memory of the original symptom to resolve safely, so it's intentionally left open/deferred rather than acted on this cycle.

Test plan

  • python3 -m compileall -q src
  • SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy python3 -m pytest — 402 passed
  • pytest --cov=src --cov-report=term-missingsrc/fishE.py 77% → 99%, repo total 95% → 96%

…aths

fishE.py's core game loop (play()) had zero test coverage, along with
several load/save exception-handling branches and the timeService.json
load path in __init__. Coverage for the file goes from 77% to 99%
(only the __main__ entry point remains untested).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric:

  • Scope: PASS — only tests/test_fishE.py changed (gh pr diff 130 --name-only); no production code, formatting, or unrelated files touched.
  • Tests-new: PASS — every new test targets a line range that was uncovered before this PR (confirmed via pytest --cov=src --cov-report=term-missing): play() (lines 195-227, previously 0% covered), loadStats/loadTimeService exception paths, save()'s missing-directory creation and write-failure handling, the __init__ path that loads timeService.json when present, and the delete/quit branches of _selectSaveFile/_deleteSaveFile.
  • Tests-fix: N/A — this is a Stage B test-expansion cycle (no production bug fixed), so there's no fix to stash/re-verify against.
  • Sibling structure: PASS — new tests follow the file's existing # prepare / # call / # check comment structure and createXxx() factory-helper pattern (e.g. createGameForPlay() mirrors createGameForPersistence()).
  • Sibling renames: N/A — no renames in this PR.
  • Docs: PASS — no user-facing or persisted behavior changed; nothing in the README/schemas/PLANNING.md needs updating for a test-only PR.
  • Issue resolution: N/A — no Closes #N. The repo's only open issue (PLANNING.md's only GOALS entry (bait price loading bug) may be stale #122) needs the repo owner's memory of the original bait-price symptom to resolve safely and is explicitly deferred (noted in the PR body), not something this cycle can close.
  • CI: PASS — green on head commit fb46751 (https://github.com/Stephenson-Software/FishE/actions/runs/30344964561).

Repo-specific:

  • Schema-sync: N/A — no persisted fields added/changed.
  • Money-format: N/A — no new money/price display.
  • Deterministic-tests: PASS — no new test depends on unseeded random.
  • Headless-pygame: N/A — no pygame code path touched.
  • camelCase: PASS — new identifiers (createGameForPlay, etc.) match the file's existing camelCase convention.

Net effect: src/fishE.py coverage 77% → 99% (only the untestable if __name__ == "__main__": entry point remains uncovered); full suite 402 passed.

@dmccoystephenson
dmccoystephenson merged commit 0e7652e into main Jul 28, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the feature/expand-fishE-play-loop-tests branch July 28, 2026 09:04
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