from card import Card from pokerhand import PokerHand from constants import * import unittest class MyUnitTestClass(unittest.TestCase): def test_1(self): cards = [Card(11, 'S'), Card(13, 'H'), \ Card(6, 'C'), Card(6, 'H'), \ Card(13, 'C')] ph = PokerHand(cards) self.assertEqual(str(ph), \ 'JS KH 6C 6H KC ') def test_straight_flush(self): cards = [Card(11, 'S'), Card(12, 'S'), \ Card(13, 'S'), Card(10, 'S'), \ Card(14, 'S')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ STRAIGHT_FLUSH) def test_4_of_a_kind(self): cards = [Card(13, 'S'), Card(13, 'H'), \ Card(13, 'C'), Card(13, 'D'), \ Card(14, 'C')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ FOUR_OF_A_KIND) cards = [Card(5, 'S'), Card(13, 'H'), \ Card(13, 'C'), Card(13, 'D'), \ Card(13, 'S')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ FOUR_OF_A_KIND) def test_full_house(self): cards = [Card(11, 'S'), Card(11, 'H'), \ Card(8, 'C'), Card(11, 'D'), \ Card(8, 'S')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ FULL_HOUSE) cards = [Card(10, 'S'), Card(14, 'H'), \ Card(14, 'C'), Card(14, 'D'), \ Card(10, 'C')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ FULL_HOUSE) def test_flush(self): cards = [Card(11, 'S'), Card(3, 'S'), \ Card(13, 'S'), Card(10, 'S'), \ Card(8, 'S')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ FLUSH) def test_straight(self): cards = [Card(11, 'S'), Card(9, 'C'), \ Card(12, 'D'), Card(10, 'S'), \ Card(8, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ STRAIGHT) def test_three_of_a_kind(self): cards = [Card(11, 'S'), Card(9, 'C'), \ Card(11, 'D'), Card(10, 'S'), \ Card(11, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ THREE_OF_A_KIND) cards = [Card(11, 'S'), Card(2, 'C'), \ Card(11, 'D'), Card(14, 'S'), \ Card(11, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ THREE_OF_A_KIND) cards = [Card(5, 'S'), Card(9, 'C'), \ Card(5, 'D'), Card(10, 'S'), \ Card(5, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ THREE_OF_A_KIND) def test_two_pair(self): cards = [Card(11, 'S'), Card(7, 'C'), \ Card(11, 'D'), Card(10, 'S'), \ Card(7, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ TWO_PAIR) cards = [Card(11, 'S'), Card(7, 'C'), \ Card(11, 'D'), Card(13, 'S'), \ Card(7, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ TWO_PAIR) cards = [Card(11, 'S'), Card(7, 'C'), \ Card(11, 'D'), Card(4, 'S'), \ Card(7, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ TWO_PAIR) def test_one_pair(self): cards = [Card(11, 'S'), Card(7, 'C'), \ Card(11, 'D'), Card(10, 'S'), \ Card(9, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ ONE_PAIR) cards = [Card(11, 'S'), Card(4, 'C'), \ Card(11, 'D'), Card(13, 'S'), \ Card(7, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ ONE_PAIR) cards = [Card(11, 'S'), Card(14, 'C'), \ Card(11, 'D'), Card(12, 'S'), \ Card(7, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ ONE_PAIR) cards = [Card(3, 'S'), Card(14, 'C'), \ Card(3, 'D'), Card(12, 'S'), \ Card(7, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ ONE_PAIR) cards = [Card(13, 'S'), Card(14, 'C'), \ Card(3, 'D'), Card(12, 'S'), \ Card(7, 'H')] ph = PokerHand(cards) self.assertEqual(ph.hand_type( ), \ NO_PAIR) if __name__ == '__main__': unittest.main( )