def test_run_win(self, foo): r = Round(100.0) p = Player(Strategy(), 1000.0) # check that we get a bet with the pot amount from the player with patch('shuffle.player.Player.bet', return_value=Bet(100.0)) as bet: # check that we update the bet following the win with patch('shuffle.bet.Bet.win') as win: r.run(p) bet.assert_called_once_with(100.0) win.assert_called_once_with(200.0)
def test_wins_losing_bet(self, foo): r = Round(90.0) b = Bet(10.0) # winning ticket set at 0.2, bet odds at 0.1 self.assertFalse(r.wins(b))
def test_winner_range(self): # run 1000 rounds to have a better confidence for n in range(1000): r = Round(100.0) winner = r.winner() self.assertTrue(winner >= 0 and winner <= 1)
def test_wins_winning_bet(self, foo): r = Round(100.0) b = Bet(100.0) # winning ticket set at 0.2, bet odds at 0.5 self.assertTrue(r.wins(b))
def test_odds(self): r = Round(100.0) b = Bet(100.0) expected = 0.5 actual = r.odds(b) self.assertEqual(expected, actual)