Skip to content

Delete tavern gamble tests that hand-roll the payout instead of calling gamble() - #166

Merged
dmccoystephenson merged 1 commit into
mainfrom
test/fix-tavern-gamble-hand-rolled-tests
Aug 3, 2026
Merged

Delete tavern gamble tests that hand-roll the payout instead of calling gamble()#166
dmccoystephenson merged 1 commit into
mainfrom
test/fix-tavern-gamble-hand-rolled-tests

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Aug 2, 2026

Copy link
Copy Markdown
Member

Summary

  • test_gamble_win_shows_correct_amount and test_gamble_loss (tests/location/test_tavern.py) hand-executed the win/loss arithmetic instead of calling Tavern.gamble() — both pass even with gamble() deleted entirely (confirmed by temporarily stubbing it out and rerunning).
  • The win test additionally encoded the wrong payout: even money (money == 150 on a $50 bet) instead of the real DICE_WIN_MULTIPLIER (5x) payout of $350 — a hardcoded assertion that could never catch a regression to that old behavior.
  • Deleted both. test_gamble_win_pays_multiple_of_bet and test_gamble_loss_via_real_loop already drive the real gamble() loop and cover the same branches correctly; folded the win test's "shows the actual amount, not $0" prompt-text check into test_gamble_win_pays_multiple_of_bet, deriving the expected figure from DICE_WIN_MULTIPLIER instead of hardcoding it.

Test plan

  • SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy python3 -m pytest tests/location/test_tavern.py — 30 passed
  • SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy python3 -m pytest — 727 passed
  • Regression check: temporarily changed winAmount = self.currentBet * DICE_WIN_MULTIPLIER to winAmount = self.currentBet (reintroducing the even-money bug) — test_gamble_win_pays_multiple_of_bet failed as expected, confirming the surviving test actually exercises the payout math. Reverted afterward.

Flagging for review: this PR deletes 78 lines from a single file, over this repo's 50-line do-not-auto-merge threshold, so per the dev-loop's merge policy it needs an explicit human decision rather than an autonomous merge even though it's test-only and CI is green.

Closes #154


drafted by Claude on behalf of Daniel Stephenson

…ng gamble()

test_gamble_win_shows_correct_amount and test_gamble_loss executed the
win/loss arithmetic themselves rather than calling Tavern.gamble(), so
they passed even with gamble() removed entirely. The win test also
encoded even-money payout ("You won $50!" on a $50 bet), which is
$300 short of the real 5x payout - a regression the suite could not
have caught.

test_gamble_win_pays_multiple_of_bet and test_gamble_loss_via_real_loop
already drive the real loop and cover the same branches correctly;
folded the win test's prompt-text check into the former, derived from
DICE_WIN_MULTIPLIER instead of hardcoded.

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

dmccoystephenson commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

Self-review rubric:

Summary: all rubric items pass, CI green, fix empirically verified by reverting and re-testing. Do-not-auto-merge match: this diff deletes 78 lines from a single file (over the repo's 50-line threshold), so per Phase 8 this needs an explicit human merge decision rather than an autonomous merge.


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 9682743 into main Aug 3, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the test/fix-tavern-gamble-hand-rolled-tests branch August 3, 2026 00:16
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.

test: two tavern gamble tests re-implement the payout instead of calling gamble(), and encode the wrong multiplier

1 participant