Ejemplo n.º 1
0
 def test_card_equals(self):
     aos1 = solution.Card(solution.RANKS["Ace"], solution.SUITS["Spades"])
     aos2 = solution.Card(solution.RANKS["Ace"], solution.SUITS["Spades"])
     self.assertEqual(aos1, aos2)
     self.assertNotEqual(
         aos1, solution.Card(solution.RANKS["Ace"],
                             solution.SUITS["Hearts"]))
Ejemplo n.º 2
0
def random_cards(count=1):
    if count == 1:
        return solution.Card(random.choice(list(solution.RANKS.values())),
                             random.choice(list(solution.SUITS.values())))

    cards = set()
    while len(cards) < count:
        cards.add(
            solution.Card(random.choice(list(solution.RANKS.values())),
                          random.choice(list(solution.SUITS.values()))))

    return cards
Ejemplo n.º 3
0
 def test_all_suits_ranks_equal(self):
     for rank in solution.RANKS.values():
         for suit in solution.SUITS.values():
             card = solution.Card(rank, suit)
             self.assertEqual(card.rank, rank())
             self.assertEqual(card.suit, suit())
Ejemplo n.º 4
0
 def test_suit_rank_equals(self):
     aos = solution.Card(solution.RANKS["Ace"], solution.SUITS["Spades"])
     self.assertEqual(aos.rank, solution.RANKS["Ace"]())
     self.assertEqual(aos.suit, solution.SUITS["Spades"]())
Ejemplo n.º 5
0
 def test_all_cards_equal(self):
     for rank in solution.RANKS.values():
         for suit in solution.SUITS.values():
             card1 = solution.Card(rank, suit)
             card2 = solution.Card(rank, suit)
             self.assertEqual(card1, card2)
Ejemplo n.º 6
0
 def test_all_card_instances(self):
     for rank in solution.RANKS.values():
         for suit in solution.SUITS.values():
             card = solution.Card(rank, suit)
             self.assertIsInstance(card.rank, rank)
             self.assertIsInstance(card.suit, suit)
Ejemplo n.º 7
0
 def test_card_instance(self):
     aos = solution.Card(solution.RANKS["Ace"], solution.SUITS["Spades"])
     self.assertIsInstance(aos.rank, solution.RANKS["Ace"])
     self.assertIsInstance(aos.suit, solution.SUITS["Spades"])
Ejemplo n.º 8
0
 def setUp(self):
     self.deck = [
         solution.Card(rank, suit) for rank in solution.RANKS.values()
         for suit in solution.SUITS.values()
     ]
Ejemplo n.º 9
0
 def test_all_to_string(self):
     for rank in solution.RANKS.values():
         for suit in solution.SUITS.values():
             card = solution.Card(rank, suit)
             self.assertEqual(str(card),
                              str(card.rank) + " of " + str(card.suit))
Ejemplo n.º 10
0
 def test_to_string(self):
     aos = solution.Card(solution.RANKS["Ace"], solution.SUITS["Spades"])
     self.assertEqual(str(aos), "Ace of Spades")