def test_sighCardWithoutAce(self): ranks = [3, 7, 11, 4, 5] suits = ['d', 'c', 'h', 's'] hand = Hand( [Card(suits[random.randint(0, 3)], ranks[i]) for i in range(5)]) assert hand.highCard() == 11
def test_notTwoPair(self): ranks = [1, 2, 3, 4, 5] suits = ['d', 'c', 'h', 's'] hand = Hand( [Card(suits[random.randint(0, 3)], ranks[i]) for i in range(5)]) assert hand.isTwoPair() == False
def test_threeOfAKind(self): ranks = [7, 7, 7, 4, 5] suits = ['d', 'c', 'h', 's'] hand = Hand( [Card(suits[random.randint(0, 3)], ranks[i]) for i in range(5)]) assert hand.isThreeOfAKind() == True
def test_straightEdgeCase(self): ranks = [10, 11, 12, 13, 1] suits = ['d', 'c', 'h', 's'] hand = Hand( [Card(suits[random.randint(0, 3)], ranks[i]) for i in range(5)]) assert hand.isStraight() == True
def test_straight(self): ranks = [1, 2, 3, 4, 5] suits = ['d', 'c', 'h', 's'] hand = Hand( [Card(suits[random.randint(0, 3)], ranks[i]) for i in range(5)]) assert hand.isStraight() == True
class Game: def __init__(self): self.deck = Deck() self.dealer_hand = Hand() self.player_hand = Hand() def start(self): self.deck.shuffle() self.player_hand.add_card(self.deck.deal()) self.dealer_hand.add_card(self.deck.deal()) self.player_hand.add_card(self.deck.deal()) self.dealer_hand.add_card(self.deck.deal()) def put_cards_back(self): for card in self.dealer_hand.cards: self.deck.add_card_on_bottom(card) for card in self.player_hand.cards: self.deck.add_card_on_bottom(card) self.dealer_hand.cards = [] self.player_hand.cards = [] self.dealer_hand.value = self.player_hand.value = 0 self.dealer_hand.aces = self.player_hand.aces = 0
def test_royalFlush(self): ranks = [1, 10, 11, 12, 13] suits = ['d', 'd', 'd', 'd', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.valueAsText == "Royal flush"
def test_fourOfAKind(self): ranks = [4, 4, 4, 4, 13] suits = ['d', 'c', 'h', 's', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.valueAsText == "Four of a kind"
def test_straightFlush(self): ranks = [1, 2, 3, 4, 5] suits = ['d', 'd', 'd', 'd', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.valueAsText == "Straight flush"
def test_flush(self): ranks = [1, 2, 7, 11, 5] suits = ['d', 'd', 'd', 'd', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.valueAsText == "Flush"
def test_fullHouse(self): ranks = [1, 1, 1, 5, 5] suits = ['d', 'c', 'h', 's', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.valueAsText == "Full House"
def test_fourOfAkindBug(self): ranks = [2, 2, 3, 4, 5] suit = ['d', 'c', 'd', 's', 'd'] hand = Hand([Card(suit[i], ranks[i]) for i in range(5)]) assert hand.isFourOfAKind() == False
def test_threeOfAKind(self): ranks = [1, 3, 3, 3, 5] suits = ['d', 'c', 'h', 's', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.valueAsText == "Three of a kind"
def test_fourOfAKind(self): ranks = [2, 2, 2, 2, 5] suits = ['d', 's', 'c', 'h', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.isFourOfAKind() == True
def test_straightFlush(): ranks = [1, 2, 3, 4, 5] suit = 'c' hand = Hand([Card(suit, ranks[i]) for i in range(5)]) assert hand.isStraightFlush() == True
def test_onePair(self): ranks = [1, 2, 2, 4, 5] suits = ['d', 'c', 'h', 's', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.valueAsText == "One pair"
def test_twoPairNotThreeOfAKind(self): ranks = [7, 7, 4, 4, 5] suits = ['d', 'c', 'h', 's', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.isThreeOfAKind() != True
def test_fullHouseRecognizedAsHighCard(self): ranks = [6, 6, 11, 11, 11] suits = ['h', 'd', 's', 'd', 'h'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.isFullHouse() == True
def test_twoPairNotFullHouse(self): ranks = [3, 3, 3, 7, 2] suits = ['d', 's', 'c', 'h', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.isFullHouse() == False
def test_fullHouse(self): ranks = [3, 3, 3, 7, 7] suits = ['d', 's', 'c', 'h', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.isFullHouse() == True
def test_highCard(self): ranks = [1, 2, 8, 4, 5] suits = ['d', 'c', 'h', 's', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.valueAsText == "Highcard of A"
def test_twoPair(self): ranks = [1, 2, 2, 4, 4] suits = ['d', 'c', 'h', 's', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.valueAsText == "Two pairs"
def test_RoyalFlush(self): ranks = [10, 11, 12, 13, 1] suit = 's' hand = Hand([Card(suit, ranks[i]) for i in range(5)]) assert hand.isRoyalFlush() == True
def test_fullHouseNotFourOfAKind(self): ranks = [3, 3, 3, 7, 7] suits = ['d', 's', 'c', 'h', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.isFourOfAKind() == False
def test_twoPair(self): ranks = [7, 7, 4, 4, 5] suits = ['d', 'c', 'h', 's', 'd'] hand = Hand([Card(suits[i], ranks[i]) for i in range(5)]) assert hand.isTwoPair() == True
def test_royalFlushShouldFail(self): ranks = [1, 2, 3, 4, 5] suit = 'c' hand = Hand([Card(suit, ranks[i]) for i in range(5)]) assert hand.isRoyalFlush() == False
def __init__(self): self.deck = Deck() self.dealer_hand = Hand() self.player_hand = Hand()
def test_Flush(): ranks = [1, 7, 11, 4, 5] suit = 'd' hand = Hand([Card(suit, ranks[i]) for i in range(5)]) assert hand.isFlush() == True