def testHands(self): self.assertEquals(poker.hand_value("Straight flush"), poker.Hand.from_str("AcKcQcJc10c").value[0]) self.assertEquals(poker.hand_value("Four of a kind"), poker.Hand.from_str("AcAdAhAs6d").value[0]) self.assertEquals(poker.hand_value("Full house"), poker.Hand.from_str("AcAdAc6s6d").value[0]) self.assertEquals(poker.hand_value("Full house"), poker.Hand.from_str("6c6d6cAsAd").value[0]) self.assertEquals(poker.hand_value("Flush"), poker.Hand.from_str("AcKcQcJc9c").value[0]) self.assertEquals(poker.hand_value("Straight"), poker.Hand.from_str("AcKcQdJc10c").value[0]) self.assertEquals(poker.hand_value("Three of a kind"), poker.Hand.from_str("AcAdAs7d6d").value[0]) self.assertEquals(poker.hand_value("Two pair"), poker.Hand.from_str("AcAd8c8d6d").value[0]) self.assertEquals(poker.hand_value("One pair"), poker.Hand.from_str("AcAd8d7d6d").value[0]) self.assertEquals(poker.hand_value("High card"), poker.Hand.from_str("AcJd8d7d6d").value[0])
def testHighestHand(self): hands = ( ("AcAd7c5c4c", "Ah", "Ac", "Four of a kind"), ("AcAd7c5c4c", "7d", "7h", "Full house"), ("AcAd7c5c4c", "8h", "6d", "Straight"), ("AcAd7c5c4c", "8c", "6c", "Straight flush"), ("AcAd7c5c4c", "8c", "6c", "Straight flush"), ("AcAd7c5c4c", "10h", "10d", "Two pair"), ("AcAd7c5c4c", "10c", "10d", "Flush"), ) for hand in hands: board = poker.Hand.from_str(hand[0]).cards player = poker.Player() player.deal(poker.Card.from_str(hand[1])) player.deal(poker.Card.from_str(hand[2])) self.assertEquals(poker.hand_value(hand[3]), player.hand(board).value[0])