def test_who_wins(): hand_cases = [(faces) for faces, ranking in cases()] for hand in hand_cases: Hands.rank(hand) sorted_cases = sorted(hand_cases, reverse=True) assert sorted(sorted_cases) == sorted(hand_cases) print('\nHigh to low order:') for i, hand in enumerate(hand_cases): print(i, hand)
def test_rank(faces, expected): hand_dict = { "royal straight flush": 23, "straight flush": 22, "back straight": 21, "four card": 20, "full house": 19, "flush": 18, "straight": 17, "three card": 16, "two pairs": 15, "one pair": 14, '2': 1, '3': 2, '4': 3, '5': 4, '6': 5, '7': 6, '8': 7, '9': 8, 'T': 9, 'J': 10, 'Q': 11, 'K': 12, 'A': 13 } random.shuffle(faces) hand = ([c for c in faces]) a = Hands.rank((hand)) assert a == hand_dict[Hands.tell_hand_ranking(hand)]