Ejemplo n.º 1
0
def test_bottom_insert_two_and_draw_yields_first_inserted_card(empty_deck):
    deck = empty_deck
    three = playing_cards.StandardPlayingCard('3', 'spades')
    five = playing_cards.StandardPlayingCard('5', 'clovers')
    deck.insert_to_bottom(three)
    deck.insert_to_bottom(five)
    drawn_card = deck.draw()
    assert drawn_card == three
Ejemplo n.º 2
0
def royal_flush_diamonds():
    ace_diamonds = playing_cards.StandardPlayingCard(ranks.ACE, suits.DIAMOND)
    king_diamonds = playing_cards.StandardPlayingCard(ranks.KING, suits.DIAMOND)
    queen_diamonds = playing_cards.StandardPlayingCard(ranks.QUEEN, suits.DIAMOND)
    jack_diamonds = playing_cards.StandardPlayingCard(ranks.JACK, suits.DIAMOND)
    ten_diamonds = playing_cards.StandardPlayingCard(ranks.TEN, suits.DIAMOND)
    hand = cards.five_card_hand.FiveCardHand([ace_diamonds, king_diamonds, queen_diamonds, jack_diamonds, ten_diamonds])
    return hand
Ejemplo n.º 3
0
def test_top_insert_two_and_draw_yields_second_inserted_card(empty_deck):
    deck = empty_deck
    ace = playing_cards.StandardPlayingCard('ace', 'spades')
    seven = playing_cards.StandardPlayingCard(7, 'clovers')
    deck.insert_to_top(ace)
    deck.insert_to_top(seven)
    drawn_card = deck.draw()
    assert seven is drawn_card
Ejemplo n.º 4
0
 def test_different_cards_unequal(self):
     queen = playing_cards.StandardPlayingCard('queen', 'hearts')
     other_cards = [playing_cards.StandardPlayingCard(rank, suit)
                    for rank in ranks.get_all_ranks()
                    for suit in suits.get_all_suits()]
     other_cards.remove(queen)
     for other_card in other_cards:
         assert queen != other_card
Ejemplo n.º 5
0
def test_remove_all_single_card(stacked_deck):
    stacked_deck.remove_all(
        playing_cards.StandardPlayingCard(ranks.ACE, suits.SPADE))
    expected_cards = [
        playing_cards.StandardPlayingCard(rank, suits.SPADE)
        for rank in [ranks.TEN, ranks.JACK, ranks.QUEEN, ranks.KING]
    ]
    for expected_card in expected_cards:
        assert expected_card in stacked_deck
    assert stacked_deck.num_cards == 4
Ejemplo n.º 6
0
def test_remove_all_except_one(empty_deck):
    deck = empty_deck
    for i in range(5):
        deck.insert_to_top(
            playing_cards.StandardPlayingCard(ranks.KING, suits.HEART))
    deck.insert_to_top(
        playing_cards.StandardPlayingCard(ranks.FOUR, suits.SPADE))
    deck.shuffle()
    deck.remove_all(ranks.KING)
    assert deck.num_cards == 1
    assert deck.draw() == playing_cards.StandardPlayingCard(
        ranks.FOUR, suits.SPADE)
Ejemplo n.º 7
0
def full_house_queens():
    hand = [playing_cards.StandardPlayingCard(ranks.QUEEN, suit) for suit in [suits.DIAMOND, suits.CLOVER, suits.SPADE]]
    hand += [playing_cards.StandardPlayingCard(ranks.SEVEN, suit) for suit in [suits.HEART, suits.SPADE]]
    return poker_hands.FullHouse(hand)
Ejemplo n.º 8
0
def flush_spades():
    hand = [playing_cards.StandardPlayingCard(rank, suits.SPADE)
            for rank in [ranks.SEVEN, ranks.QUEEN, ranks.ACE, ranks.TWO, ranks.TEN]]
    return poker_hands.Flush(hand)
Ejemplo n.º 9
0
def four_of_a_kind_9s():
    hand = [playing_cards.StandardPlayingCard(ranks.NINE, suit) for suit in suits.get_all_suits()]
    hand.append(playing_cards.StandardPlayingCard(ranks.FOUR, suits.CLOVER))
    return cards.five_card_hand.FiveCardHand(hand)
Ejemplo n.º 10
0
 def test_four_of_a_kind(self, four_of_a_kind_9s):
     four_of_a_kind_9s = cards.classify_hand.classify(four_of_a_kind_9s)
     assert four_of_a_kind_9s.get_dominant_rank() == ranks.NINE
     assert four_of_a_kind_9s.get_kicker() == playing_cards.StandardPlayingCard(ranks.FOUR, suits.CLOVER)
Ejemplo n.º 11
0
def high_card():
    hand = [playing_cards.StandardPlayingCard(rank, suits.DIAMOND) for rank in ranks.get_all_ranks()[:4]]
    hand += [playing_cards.StandardPlayingCard(ranks.TEN, suits.CLOVER)]
    return poker_hands.HighCard(hand)
Ejemplo n.º 12
0
 def test_bad_rank_raises_exception(self):
     with pytest.raises(exceptions.IllegalRankException):
         playing_cards.StandardPlayingCard('potato', 'spades')
Ejemplo n.º 13
0
def straight_ace_high():
    hand = [playing_cards.StandardPlayingCard(rank, suits.CLOVER) for rank in [ranks.TEN, ranks.JACK, ranks.QUEEN, ranks.KING]]
    hand.append(playing_cards.StandardPlayingCard(ranks.ACE, suits.DIAMOND))
    return cards.five_card_hand.FiveCardHand(hand)
Ejemplo n.º 14
0
def two_pair():
    hand = [playing_cards.StandardPlayingCard(ranks.THREE, suit) for suit in suits.get_black_suits()]
    hand += [playing_cards.StandardPlayingCard(ranks.FIVE, suit) for suit in suits.get_red_suits()]
    hand += [playing_cards.StandardPlayingCard(ranks.QUEEN, suits.DIAMOND)]
    return poker_hands.TwoPair(hand)
Ejemplo n.º 15
0
 def test_card_identity_property(self):
     king = playing_cards.StandardPlayingCard('King', 'diamonds')
     assert king == king
Ejemplo n.º 16
0
 def test_same_cards_equal(self):
     seven = playing_cards.StandardPlayingCard(7, 'Clover')
     seven_2 = playing_cards.StandardPlayingCard(7, 'Clover')
     assert seven == seven_2
Ejemplo n.º 17
0
 def test_text(self):
     ace = playing_cards.StandardPlayingCard('Ace', 'Spade')
     assert ace.name == 'Ace of Spades'
Ejemplo n.º 18
0
 def test_suit(self):
     ace = playing_cards.StandardPlayingCard('Ace', 'Spade')
     assert ace.suit == 'Spade'
Ejemplo n.º 19
0
 def test_rank(self):
     ace = playing_cards.StandardPlayingCard('Ace', 'Spade')
     assert ace.rank == 'Ace'
Ejemplo n.º 20
0
def straight():
    hand = [playing_cards.StandardPlayingCard(rank, suits.HEART) for rank in ranks.get_all_ranks()[3:7]]
    hand.append(playing_cards.StandardPlayingCard(ranks.NINE, suits.CLOVER))
    return poker_hands.Straight(hand)
Ejemplo n.º 21
0
def stacked_deck():
    deck = Deck()
    for rank in ranks.get_royals():
        card = playing_cards.StandardPlayingCard(rank, 'spade')
        deck.insert_to_top(card)
    return deck
Ejemplo n.º 22
0
def three_of_a_kind():
   hand = [playing_cards.StandardPlayingCard(ranks.SIX, suit) for suit in [suits.SPADE, suits.HEART, suits.DIAMOND]]
   hand += [playing_cards.StandardPlayingCard(ranks.NINE, suits.CLOVER), playing_cards.StandardPlayingCard(ranks.TWO, suits.SPADE)]
   return poker_hands.ThreeOfAKind(hand)
Ejemplo n.º 23
0
 def test_iterator(self, royal_flush_diamonds):
     ranks_to_expect = reversed([ranks.TEN, ranks.JACK, ranks.QUEEN, ranks.KING, ranks.ACE])
     cards_to_expect = [playing_cards.StandardPlayingCard(rank, suits.DIAMOND) for rank in ranks_to_expect]
     for expected_card, actual_card in zip(cards_to_expect, royal_flush_diamonds):
         assert expected_card == actual_card
Ejemplo n.º 24
0
def one_pair():
    hand = [playing_cards.StandardPlayingCard(ranks.TWO, suit) for suit in suits.get_black_suits()]
    hand += [playing_cards.StandardPlayingCard(rank, suits.CLOVER) for rank in [ranks.QUEEN, ranks.FIVE, ranks.TEN]]
    return poker_hands.OnePair(hand)
Ejemplo n.º 25
0
def test_bottom_insert_and_draw_yields_same_card(empty_deck):
    deck = empty_deck
    inserted_card = playing_cards.StandardPlayingCard('Jack', 'diamonds')
    deck.insert_to_bottom(inserted_card)
    drawn_card = deck.draw()
    assert inserted_card == drawn_card
Ejemplo n.º 26
0
def straight_ace_low():
    hand = [playing_cards.StandardPlayingCard(rank, suits.CLOVER) for rank in [ranks.ACE, ranks.TWO, ranks.THREE, ranks.FOUR]]
    hand.append(playing_cards.StandardPlayingCard(ranks.FIVE, suits.DIAMOND))
    return cards.five_card_hand.FiveCardHand(hand)
Ejemplo n.º 27
0
 def test_bad_suit_raises_exception(self):
     with pytest.raises(exceptions.IllegalSuitException):
         playing_cards.StandardPlayingCard('ace', 'bunnies')
Ejemplo n.º 28
0
def straight_flush_spades_5_high():
    hand = [playing_cards.StandardPlayingCard(rank, suits.SPADE)
            for rank in [ranks.ACE, ranks.TWO, ranks.THREE, ranks.FOUR, ranks.FIVE]]
    return cards.classify_hand.classify(hand)
Ejemplo n.º 29
0
 def test_init(self):
     playing_cards.StandardPlayingCard('Ace', 'Spade')