def test_sort_order(self): cards = Card.from_masks([d3.mask, d4.mask]) cards.sort() self.assertListEqual([card.mask for card in cards], [d3.mask, d4.mask]) cards = Card.from_masks([d4.mask, d3.mask]) cards.sort() self.assertListEqual([card.mask for card in cards], [d3.mask, d4.mask])
def setUp(self): self.deck = Deck(Card.create_cards()) self.poker_manager = PokerManager() self.poker_manager.reset(self.deck, random)
def setUp(self): self.deck = Deck(Card.create_cards(with_joker=True))
def test_eq(self): self.assertEqual(Card.from_mask(Card.DIAMOND_THREE.mask), Card.from_mask(Card.DIAMOND_THREE.mask)) self.assertEqual(Card.from_mask(Card.DIAMOND_THREE.mask), Card(Card.SUIT_DIAMOND, Card.RANK_THREE))
def test_invalid_add(self): card = Card(Card.SUIT_DIAMOND, Card.RANK_TWO) with self.assertRaises(InvalidInstance): card + 20 with self.assertRaises(TypeError): card + '1'
def test_sub(self): card = Card(Card.SUIT_DIAMOND, Card.RANK_FOUR) self.assertEqual(card - 1, Card(Card.SUIT_DIAMOND, Card.RANK_THREE))
def test_add(self): card = Card(Card.SUIT_DIAMOND, Card.RANK_THREE) self.assertEqual(card + 1, Card(Card.SUIT_DIAMOND, Card.RANK_FOUR))
def test_str(self): card = Card(Card.SUIT_DIAMOND, Card.RANK_TWO) self.assertEqual(str(card), '[DIAMOND,TWO]')
def test_masks(self): card = Card(Card.SUIT_DIAMOND, Card.RANK_TWO) card2 = Card(Card.SUIT_DIAMOND, Card.RANK_THREE) self.assertListEqual(Card.from_masks([d2.mask, d3.mask]), [card, card2])
def test_mask(self): card = Card(Card.SUIT_DIAMOND, Card.RANK_TWO) self.assertEqual(card.mask, d2.mask) self.assertEqual(Card.from_mask(d2.mask), card)
def test_invalid(self): with self.assertRaises(InvalidInstance): Card.from_mask(1) with self.assertRaises(InvalidInstance): Card(10, 10)
def test_special(self): Card(Card.SUIT_SPECIAL, Card.RANK_TWO)