コード例 #1
0
ファイル: test-Hand.py プロジェクト: von/pyPoker
 def test_combinations_of_eight_or_lower(self):
     """Test combinations_of_eight_or_lower() method"""
     h = Hand.fromString("AC 2D 3H 4S TH")
     self.assert_iterator(h.combinations_of_eight_or_lower(5),
                          count=0)
     h = Hand.fromString("AC 2D 3H 4S 5H")
     self.assert_iterator(h.combinations_of_eight_or_lower(5),
                          count=1,
                          assert_item_function=lambda i: len(i)==5)
コード例 #2
0
ファイル: test-Hand.py プロジェクト: von/pyPoker
 def test_too_many_cards(self):
     """Test adding too many cards to a hand."""
     hand = Hand.fromString("AC 2C 3C 4C 5C")
     self.assertEquals(len(hand), 5)
     with self.assertRaises(TooManyCardsException):
         hand.append(Card.fromString("6C"))
     self.assertEquals(len(hand), 5)
コード例 #3
0
ファイル: test-Hand.py プロジェクト: thecowboy/pyPoker
 def testCombinations(self):
     """Test basic hand combinatins."""
     hand = Hand.fromString("8C 9D 7C 6S AH")
     count = 0
     for combs in hand.combinations(2):
         count += 1
         self.assertEquals(len(combs), 2)
     self.assertEquals(count, 10)
コード例 #4
0
ファイル: test-Ranker.py プロジェクト: thecowboy/pyPoker
 def testRankHand(self):
     """Test rankHand() mathod."""
     rank = self.ranker.rankHand(Hand.fromString("JC TS 9D 6H 2C"))
     self.assertIsNotNone(rank)
     self.assertIsInstance(rank, PokerRank, type(rank))
     self.assertNotEqual(rank, 0)
     rankType = rank.getType()
     self.assertEqual(rankType, PokerRank.HIGH_CARD,
                      "rank = (%s) %d != HIGH_CARD" % (str(rankType), rankType))
コード例 #5
0
ファイル: test-Hand.py プロジェクト: thecowboy/pyPoker
 def testHandConstruction(self):
     """Test basic hand construction"""
     hand = Hand.fromString("8C")
     self.assertEquals(hand[0].suit, Suit.CLUBS)
     self.assertEquals(hand[0].rank, Rank.EIGHT)
     hand.addCardsFromString("9D TH")
     self.assertEquals(hand[1].suit, Suit.DIAMONDS)
     self.assertEquals(hand[1].rank, Rank.NINE)
     self.assertEquals(hand[2].suit, Suit.HEARTS)
     self.assertEquals(hand[2].rank, Rank.TEN)
コード例 #6
0
ファイル: test-LowRanker.py プロジェクト: von/pyPoker
    def testBasicLowRanking(self):
	"""Verify ranking for low hand."""
	rank = self.ranker.rankHand(Hand.fromString("AS 8C 7S 4D 3H"))
	self.assertEqual(rank.getType(), PokerRank.HIGH_CARD,
                         "%s != HIGH_CARD" % rank)
	self.assertEqual(rank.getPrimaryCardRank(), Rank.EIGHT,
			 "%s != 8, kickers = %s" % (rank.getPrimaryCardRank(),
						    rank.kickersAsString()))
	self.assertEqual(rank.isEightOrBetterLow(), True,
			 "\"%s\".isEightOrBetterLow() != True" % rank)
        kickers = rank.getKickerRanks()
        self.assertEqual(len(kickers), 4,
                         "len(kickers) = %d != 4" % len(kickers))
        self.assertEqual(kickers[0], Rank.SEVEN,
                         "kickers[0] == %s != SEVEN" % kickers[0])
        self.assertEqual(kickers[1], Rank.FOUR,
                         "kickers[1] == %s != FOUR" % kickers[1])
        self.assertEqual(kickers[2], Rank.THREE,
                         "kickers[2] == %s != THREE" % kickers[2])
        self.assertEqual(kickers[3], Rank.ACE_LOW,
                         "kickers[3] == %s != ACE (low)" % kickers[3])
コード例 #7
0
ファイル: test-LowRanker.py プロジェクト: von/pyPoker
 def testBestHand(self):
     """Test bestHand() method"""
     hands = [
         Hand.fromString("AC 9D KS 3D KH"), # Pair of Kings
         Hand.fromString("9C TS QH JC 8H"), # Q-high
         Hand.fromString("KD TH 7C 6C 2H"), # K-high
         Hand.fromString("AD JD 8D 4D 2D"), # J-high
         Hand.fromString("7S QD QS QC 6D"), # Trip queens
         Hand.fromString("8S 7C 2C 3D 5H"), # 8-high
         ]
     best_hands, best_rank = self.ranker.bestHand(hands)
     self.assertIsNotNone(best_hands)
     self.assertIsInstance(best_hands, list)
     self.assertEqual(len(best_hands), 1)
     self.assertEqual(best_hands[0], 5) # 8-high
     self.assertIsNotNone(best_rank)
     self.assertIsInstance(best_rank, PokerRank)
     self.assertEqual(best_rank.getType(), PokerRank.HIGH_CARD)
     self.assertEqual(best_rank.getPrimaryCardRank(), Rank.EIGHT)
コード例 #8
0
ファイル: test-Hand.py プロジェクト: von/pyPoker
 def test_get_public_string(self):
     """Test get_public_string() method"""
     hand = Hand.fromString("9D 3C 5S")
     self.assertEqual(hand.get_public_string(), "XX XX XX")
     hand2 = Hand()
     self.assertEqual(hand2.get_public_string(), "")
コード例 #9
0
ファイル: test-Hand.py プロジェクト: von/pyPoker
    def testCombinations(self):
	"""Test basic hand combinatins."""
	hand = Hand.fromString("8C 9D 7C 6S AH")
        self.assert_iterator(hand.combinations(2),
                             count=10,
                             assert_item_function=lambda i: len(i)==2)