def test_getWinners_returns_list_winning_hands(self, dealer_hand, hand): dealer_hand.cards = [Card.generate('A'), Card.generate('T')] hand.cards = [Card.generate('T'), Card.generate('T')] hands = [dealer_hand, hand] winners = Game.getWinners(hands) assert type(winners) is list assert "Dealer" in winners
def test_is_blackjack(self, player, sec_hand): hand = Hand(player) ace = Card.generate('A') hand.cards.append(ace) hand.cards.append(Card.generate(sec_hand)) assert len([c for c in hand.cards if c.type == 'high']) == 2 assert hand.is_soft assert hand.is_blackjack
def test_is_paired(self, player): hand = Hand(player) hand.cards.append(Card.generate('T')) hand.cards.append(Card.generate('T')) assert hand.is_paired hand.cards.pop() hand.cards.append(Card.generate('8')) assert not hand.is_paired
def test_is_soft(self, player): hand = Hand(player) ace = Card.generate('A') hand.cards.append(ace) hand.cards.append(Card.generate('9')) assert hand.is_soft hand.cards.remove(ace) hand.cards.append(Card.generate('T')) assert not hand.is_soft
def __init__(self, decks=1): """ Instantiate the Shoe, it's cards basing on deck numbers :param decks: Number of decks that make up the shoe """ self.cards = [] for i in range(decks): self.cards.extend( [Card(rank=r, suit=s) for s in Card.suits for r in Card.ranks])
def test_type_is_high(self, rank): assert Card.generate(rank).type == 'high'
def test_high_ranks_value_1(self, rank): assert Card.generate(rank).value == 1
def test_ranks_7_to_9_value_0(self, rank): assert Card.generate(rank).value == 0
def test_ranks_6_or_less_value_negative_1(self, rank): assert Card.generate(rank).value == -1
def test_rank_A_weight_11(self): assert Card.generate('A').weight == 1
def test_ranks_9_or_less_weight_rank(self, rank): assert Card.generate(rank).weight == int(rank)
def _generate_card(value): card = Card(value) return card
def test_aces_not_blackjack(self, player): hand = Hand(player) hand.cards.append(Card.generate('A')) hand.cards.append(Card.generate('A')) assert not hand.is_blackjack
def test_non_aced_is_hard(self, player): hand = Hand(player) hand.cards.append(Card.generate('T')) hand.cards.append(Card.generate('T')) assert not hand.is_soft
def test_type_is_low(self, rank): assert Card.generate(rank).type == 'low'
def test_high_cards_weigh_10(self, rank): assert Card.generate(rank).weight == 10
def test_faced_by_default(self): card = Card.generate('T') assert card.is_face_up
def test_totals(self, hand, pair, totals): rank1, rank2 = pair hand.cards.append(Card.generate(rank1)) hand.cards.append(Card.generate(rank2)) assert hand.totals == totals