def test_action_basic_strategy_low_bankroll_split_soft(self): player = Player({'bankroll': 0, 'game_settings': PlayerTest.game_settings}) hand = build_hand('soft_pair') hand.bet = 1 self.assertEqual(PlayerAction.HIT, player.action(hand, Card('5', 5, 'clubs')))
def test_card_str_value(): """Ensure the string value given the card""" ace_spades = Card("A", "spades") ace_spades_string = ( "\x1b[47m\x1b[30m\nA \n\u2660 \n \u2660 \n \u2660\n A" ) queen_hearts = Card("Q", "hearts") queen_hearts_string = ( "\x1b[47m\x1b[31m\nQ \n\u2665 \n \u265B \n \u2665\n Q" ) # Pair cards together real_cards = [ace_spades, queen_hearts] test_cards = [ace_spades_string, queen_hearts_string] test_pairs = list(zip(real_cards, test_cards)) for real_card, test_card in test_pairs: assert str(real_card) == test_card
def test___str__(self): card = Card(TestCard.test_card_rank, TestCard.test_card_value, TestCard.test_card_suit) self.assertEqual(str(card), '{} - {}'.format(TestCard.test_card_rank, TestCard.test_card_suit.title()))
from blackjack.cards import Card HANDS = { 'blackjack': { 'cards': [Card('Q', 10, 'clubs'), Card('A', 11, 'spades')], 'score': 21, 'blackjack': True, 'bust': False, 'soft': True }, 'bust': { 'cards': [ Card('5', 5, 'hearts'), Card('K', 10, 'diamonds'), Card('J', 10, 'clubs') ], 'score': 25, 'blackjack': False, 'bust': True, 'soft': False, }, 'double_down': { 'cards': [Card('5', 5, 'hearts'), Card('6', 6, 'diamonds')], 'score': 11, 'blackjack': False,
def test_action_basic_strategy_soft(self): player = Player({'game_settings': PlayerTest.game_settings}) hand = build_hand('soft') self.assertEqual(PlayerAction.HIT, player.action(hand, Card('K', 10, 'clubs')))
def test_action_basic_strategy_double_down_with_three_cards(self): player = Player({'game_settings': PlayerTest.game_settings}) hand = build_hand('three_card_11') self.assertEqual(PlayerAction.HIT, player.action(hand, Card('K', 10, 'clubs')))
def test_action_basic_strategy_double_down(self): player = Player({'game_settings': PlayerTest.game_settings}) hand = build_hand('double_down') self.assertEqual(PlayerAction.DOUBLE_DOWN, player.action(hand, Card('5', 5, 'clubs')))
def test_action_basic_strategy_blackjack(self): player = Player({'game_settings': PlayerTest.game_settings}) hand = build_hand('blackjack') self.assertEqual(PlayerAction.STAND, player.action(hand, Card('K', 10, 'clubs')))
def test_hand_string(player): cards = [Card("Hearts", x) for x in ["A", "10", "4"]] player.hand = cards expected = "A.Hearts 10.Hearts 4.Hearts" assert expected == player.str_hand()
def test_check_card_count_ace_over_21(player): cards = [Card("Hearts", x) for x in ["A", "10", "4"]] player.hand = cards assert player.card_count == 15
def test_check_card_count(player): cards = [Card("Hearts", x) for x in ["2", "3", "4"]] player.hand = cards assert player.card_count == 9