コード例 #1
0
def test_empty_deck():
    deck = Deck(card_nums=[1])
    deck.deal_one()
    deck.deal_one()
    assert len(deck.cards) == 51
    # should shuffle
    nums = [card.num for card in deck.cards]
    unshuffled = Deck()
    unshuffled.deal_one()
    ordered_nums = [card.num for card in unshuffled.cards]
    assert nums != ordered_nums
コード例 #2
0
 def test_double_down(self):
     player = Player(bank=Bank(10), bet_amount=5)
     deck = Deck(card_nums=[10, 9, 10, 5, 5])
     game = Game(player=player, deck=deck)
     game.start()
     assert player.balance == 5
     assert player.total == 10
     player.double_down(deck.deal_one())
     # Should double bet and withdraw
     assert player.balance == 0
     assert player.total == 20
     game.dealer_go()
     assert game.dealer.total == 19
     assert player.status == Statuses["WIN"]
     # Should win double original bet
     assert player.balance == 20