def test_game_settle(prints, player_cards, dealer_cards, player_bet, expected_player_purse): """ Round of Blackjack settled. """ def test_print(message): _print = prints.pop(0) assert message == _print game = Game(_print=test_print) game.get_player().get_hand().set_cards(player_cards) game.get_dealer().get_hand().set_cards(dealer_cards) game.get_player().make_bet(player_bet) game.settle() expected_player_cards = [] expected_player_bet = 0 expected_player_purse = expected_player_purse expected_dealer_cards = [] actual_player_cards = game.get_player().get_hand().get_cards() actual_player_bet = game.get_player().get_bet().get_size() actual_player_purse = game.get_player().get_purse().get_size() actual_dealer_cards = game.get_dealer().get_hand().get_cards() assert actual_player_cards == expected_player_cards assert actual_player_bet == expected_player_bet assert actual_player_purse == expected_player_purse assert actual_dealer_cards == expected_dealer_cards
def test_game_hit_dealer(prints, prompts, inputs, cards, new_card, expected): """ A dealer can hit, stay, or bust. """ def test_print(message): _print = prints.pop(0) assert message == _print game = Game(_print=test_print) game.get_dealer().get_hand().set_cards(cards) actual = game.hit_dealer(new_card) assert actual == expected
def test_game_deal(): """ A hand is dealt to a player and a dealer. """ def _random(start, end): return start game = Game(_random=_random) game.deal() hidden_card = Card('Clubs', '4') hidden_card.set_hidden(True) expected_dealer_cards = [Card('Clubs', '2'), hidden_card] expected_player_cards = [Card('Spades', 'Ace'), Card('Clubs', '3')] actual_dealer_cards = game.get_dealer().get_hand().get_cards() actual_player_cards = game.get_player().get_hand().get_cards() assert len(actual_dealer_cards) == len(expected_dealer_cards) for i in range(len(actual_dealer_cards)): assert actual_dealer_cards[i].get_suit( ) == expected_dealer_cards[i].get_suit() assert actual_dealer_cards[i].get_pip( ) == expected_dealer_cards[i].get_pip() assert actual_dealer_cards[i].get_hidden( ) == expected_dealer_cards[i].get_hidden() assert len(actual_player_cards) == len(expected_player_cards) for i in range(len(actual_player_cards)): assert actual_player_cards[i].get_suit( ) == expected_player_cards[i].get_suit() assert actual_player_cards[i].get_pip( ) == expected_player_cards[i].get_pip() assert actual_player_cards[i].get_hidden( ) == expected_player_cards[i].get_hidden()