예제 #1
0
    def test_complete(self):
        suits = {}
        for card in ALL_CARDS:
            suit_ = suit(card)
            suits[suit_] = suits.get(suit_, 0) + 1

        self.assertEqual(suits, {
            'Hearts': 13,
            'Diamonds': 13,
            'Spades': 13,
            'Clubs': 13,
            'Joker': 2,
        })
예제 #2
0
 def test_capitalised(self):
     for rank_, suit_ in itertools.product(ALL_RANKS, ALL_SUITS):
         card = '{rank}_of_{suit}'.format(rank=rank_, suit=suit_.upper())
         with self.assertRaises(ValueError):
             suit(card)
예제 #3
0
 def test_flipped(self):
     for rank_, suit_ in itertools.product(ALL_RANKS, ALL_SUITS):
         card = '{suit}_of_{rank}'.format(rank=rank_, suit=suit_)
         with self.assertRaises(ValueError):
             suit(card)
예제 #4
0
 def test_jokers(self):
     self.assertEqual(suit('Red_Joker'), 'Joker')
     self.assertEqual(suit('Black_Joker'), 'Joker')
예제 #5
0
 def test_basic(self):
     self.assertEqual(suit('Ace_of_Spades'), 'Spades')
예제 #6
0
 def test_reversable(self):
     for rank_, suit_ in itertools.product(ALL_RANKS, ALL_SUITS):
         card = '{rank}_of_{suit}'.format(rank=rank_, suit=suit_)
         self.assertEqual(suit(card), suit_)