本文整理汇总了Python中table.Table.place_bet方法的典型用法代码示例。如果您正苦于以下问题:Python Table.place_bet方法的具体用法?Python Table.place_bet怎么用?Python Table.place_bet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table.Table
的用法示例。
在下文中一共展示了Table.place_bet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TableTestCase
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import place_bet [as 别名]
class TableTestCase(unittest.TestCase):
"""Test Table class methods."""
def setUp(self):
# create table
self.table = Table()
self.table.limit = 1000
# create outcomes
self.outcome_five = Outcome("00-0-1-2-3", RouletteGame.FiveBet)
self.outcome_zero = Outcome("Number 0", RouletteGame.StraightBet)
# create bets
self.bet_five = Bet(100, self.outcome_five)
self.bet_zero = Bet(100, self.outcome_zero)
self.bet_zero_big = Bet(1100, self.outcome_zero)
def test_is_valid(self):
"""Test is_valid method."""
# check valid bets
self.assertTrue(self.table.is_valid(self.bet_five))
self.assertTrue(self.table.is_valid(self.bet_zero))
# check invalid bet
self.assertFalse(self.table.is_valid(self.bet_zero_big))
def test_place_bet(self):
"""Test place_bet method."""
# place valid bet
self.table.place_bet(self.bet_five)
# check is in bets list
self.assertIn(self.bet_five, self.table.bets)
# attempt to place invalid bet
self.assertRaises(InvalidBet, self.table.place_bet, self.bet_zero_big)
示例2: test_place_bet
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import place_bet [as 别名]
def test_place_bet():
wheel = create_wheel()
table = Table(wheel)
zerozero = Outcome("00", 35)
zerozero_bet = Bet(900, zerozero)
red_bet = Bet(60, Outcome("Red", 1))
table.place_bet(zerozero_bet)
table.place_bet(red_bet)
assert [x.bet_amount for x in table] == [900, 60]
with pytest.raises(InvalidBet):
table.place_bet(red_bet)