Exemplo n.º 1
0
def test_Poker():
	"Test cases for the functions in poker program"
	sf = "6C 7C 8C 9C TC".split() # Straight Flush
	fk = "9D 9H 9S 9C 7D".split() # Four of a Kind
	fh = "TD TC TH 7C 7D".split() # Full House
	tp = "5S 5D 9H 9C 6S".split() # Two Pairs
	fkranks = poker.cardRanks(fk)
	tpranks = poker.cardRanks(tp)
	assert poker.allMax([1, 2, 3, 3, 3, 2]) == [3, 3, 3 ]
	assert poker.kind(4, fkranks) == 9
	assert poker.kind(3, fkranks) == None
	assert poker.kind(2, fkranks) == None
	assert poker.kind(1, fkranks) == 7
	assert poker.twoPair(fkranks) == None
	assert poker.twoPair(tpranks) == (9, 5)
	assert poker.cardRanks(sf) == [10, 9, 8, 7, 6]
	assert poker.cardRanks(fk) == [9, 9, 9, 9, 7 ]
	assert poker.cardRanks(fh) == [10, 10, 10, 7, 7]
	assert poker.straight([9, 8, 7, 6, 5]) == True
	assert poker.straight([9, 8, 7, 6, 4]) == False
	assert poker.flush(sf) == True
	assert poker.flush(fk) == False
	assert poker.poker( [ sf, fk, fh ] ) == [sf]
	assert poker.poker( [ fk, fh ] ) == [fk]
	assert poker.poker( [ fh, fh ] ) == [fh, fh]
	assert poker.poker( [ sf, fh ] ) == [sf]
	assert poker.poker( [ sf ] + 99 * [ fh ] ) == [sf]
	assert poker.handRank( sf ) == ( 8, 10 )
	assert poker.handRank( fk ) == ( 7, 9, 7 )
	assert poker.handRank( fh ) == ( 6, 10, 7 )
	return "tests pass"
Exemplo n.º 2
0
 def test_straight_tester_3(self):
     '''testcase normal flush
     fl = ['4H','6H','7H','8H','9H']
     '''
     fl = ['4H','6H','7H','8H','9H']
     actual = poker.straight(fl)
     expected = False
     self.assertEqual (actual,expected)
Exemplo n.º 3
0
 def test_poker_straight(self):
     '''testcase poker normal poker
     sf = ['JC','TC','9C','8C','7C']
     fk = ['4S','4D','4C','4H','AD']
     '''
     actual = poker.straight(['JC','TC','9C','8C','7C'])
     expected = True
     self.assertEqual (actual,expected)
Exemplo n.º 4
0
 def test_straight_tester_1(self):
     '''testcase high straight
     st = ['AC','KD','QH','JS','TS']
     '''
     st = ['AC','KD','QH','JS','TS']
     actual = poker.straight(st)
     expected = True
     self.assertEqual (actual,expected)
Exemplo n.º 5
0
 def test_straight_tester_2(self):
     '''testcase normal straight_flush
     sf = ['5H','6H','7H','8H','9H']
     '''
     sf = ['5H','6H','7H','8H','9H']
     actual = poker.straight(sf)
     expected = True
     self.assertEqual (actual,expected)
Exemplo n.º 6
0
    def test_straight_2(self):
        """
        Test straight with four of a kind hand

        ['6H', '6S', '6D', '6C', 'KS']
        """
        fk = ['6H', '6S', '6D', '6C', 'KS']
        actual = poker.straight(fk)
        expected = False,0
        self.assertEqual(actual,expected)
Exemplo n.º 7
0
    def test_straight(self):
        """
        Test straight with straight hand

        ['4H', '5S', '3D', '6C', '7S']
        """
        st = ['4H', '5S', '3D', '6C', '7S']
        actual = poker.straight(st)
        expected = True,6
        self.assertEqual(actual,expected)
 def test_poker_straight_2(self):
     '''Test Case straight 2 '''
     actual = poker.straight(['6H', 'TC', '9D', '8C', '2C'])
     expected = False
     self.assertEqual(actual, expected)
Exemplo n.º 9
0
 def test_poker_example_10(self):
     sf = ["AC", "2C", "3C", "4C", "5C"]
     actual = poker.straight(sf)
     expected = True
     self.assertEqual(actual, expected)
Exemplo n.º 10
0
 def test_poker_example_9(self):
     sf = ["6C", "TC", "9C", "8C", "7C"]
     actual = poker.straight(sf)
     expected = True
     self.assertEqual(actual, expected)
Exemplo n.º 11
0
 def test_poker_example_8(self):
     sf = ["JC", "TC", "AC", "KC", "QC"]
     actual = poker.straight(sf)
     expected = True
     self.assertEqual(actual, expected)
Exemplo n.º 12
0
 def test_poker_straight2(self):
     '''Test case for checking straight'''
     actual = poker.straight(['3C','2D','5D','AC','4D'])
     expected = True
     self.assertEqual(actual, expected)
Exemplo n.º 13
0
 def test_poker_straight_1(self):
     '''Test Case straight 1 '''
     actual = poker.straight(['6H', 'TC', '9D', '8C', '7C'])
     expected = True
     self.assertEqual(actual, expected)
Exemplo n.º 14
0
 def test_straight(self):
     hand = ["2C", "3H", "4C", "5H", "6C"]
     self.assertTrue(straight(card_ranks(hand)))
Exemplo n.º 15
0
 def test_straight_rank1(self):
     self.assertEqual(poker.straight(self.rank1), True, 'Should be True')
Exemplo n.º 16
0
 def test_poker_straight_1(self):
     '''Test Case straight 1 '''
     actual = poker.straight(['6H', 'TC', '9D', '8C', '7C'])
     expected = True
     self.assertEqual(actual, expected)
Exemplo n.º 17
0
 def test_check_straight(self):
     hand1 = poker.straight([['5', '6', '7', '8', '9'], ['C', 'S', 'C', 'H', 'S']])
     self.assertEqual(hand1, 5)
     hand2 = poker.straight([['A', '6', 'T', '8', '9'], ['C', 'S', 'C', 'H', 'D']])
     self.assertEqual(hand2, 0)
Exemplo n.º 18
0
 def test_straight_rank3(self):
     self.assertEqual(poker.straight(self.rank3), False, 'Should be False')
Exemplo n.º 19
0
 def test_poker_straight2(self):
     '''Test case for checking straight'''
     actual = poker.straight(['3C', '2D', '5D', 'AC', '4D'])
     expected = True
     self.assertEqual(actual, expected)
Exemplo n.º 20
0
 def test_not_straight(self):
     hand = ["2C", "3H", "4C", "7H", "8C"]
     self.assertFalse(straight(card_ranks(hand)))
Exemplo n.º 21
0
 def test_poker_straight3(self):
     '''Test case for checking straight'''
     actual = poker.straight(['JC', 'KD', 'QD', 'AC', 'TD'])
     expected = True
     self.assertEqual(actual, expected)
Exemplo n.º 22
0
 def test_poker_straight_2(self):
     '''Test Case straight 2 '''
     actual = poker.straight(['6H', 'TC', '9D', '8C', '2C'])
     expected = False
     self.assertEqual(actual, expected)
Exemplo n.º 23
0
	def test_straight_1(self):
		'''Test straight with ['5S', '2H', '3D', '4C', '6S']'''
		
		actual = poker.straight(['5S', '2H', '3D', '4C', '6S'])
		expected = True
		self.assertEqual(actual, expected)
Exemplo n.º 24
0
 def test_poker_straight3(self):
     '''Test case for checking straight'''
     actual = poker.straight(['JC','KD','QD','AC','TD'])
     expected = True
     self.assertEqual(actual, expected) 
Exemplo n.º 25
0
	def test_straight_2(self):
		'''Test straight with ['AS', '8C', '2S', '4H', '8D']'''
		
		actual = poker.straight(['AS', '8C', '2S', '4H', '8D'])
		expected = False
		self.assertEqual(actual, expected)