Ejemplo n.º 1
0
    def test_eq(self):
        h3 = Card('h3')
        group = CardSet(h3)
        self.assertFalse(h3 == group)

        h2 = Card('h2')
        h4 = Card('h4')
        h5 = Card('h5')
        h6 = Card('h6')

        h2.assign_wildcard_attrs()  # assign 'h' and 4 as hidden attrs
        group1 = CardSet([h2, h5, h6])
        group2 = CardSet([h4, h5, h6])
        self.assertTrue(h2 == h4)
        self.assertTrue(group1 == group2)
        self.assertTrue(group1.contains(group2))

        group2.remove(
            h2
        )  # since h2 and h4 are equal, removing h2 should in effect remove h4
        self.assertTrue(group2 == CardSet([h5, h6]))

        group2 = CardSet([h4, h5, h6])
        group2.remove(CardSet([h2, h5]))
        print(group2)
        self.assertTrue(group2 == CardSet([h6]))
Ejemplo n.º 2
0
    def test_remove(self):
        # case 1: removing a card object
        h3 = Card('h3')
        h4 = Card('h4')
        h5 = Card('h5')
        group = CardSet([h3, h4, h5])
        card2remove = h3
        group.remove(card2remove)
        self.assertTrue(group == CardSet([h4, h5]))
        self.assertFalse(group.contains(h3))
        self.assertFalse(h3.isin(group))

        # case 2: removing a card_set object
        group = CardSet([h3, h4, h5])
        to_remove = CardSet([h3, h4])
        group.remove(to_remove)
        self.assertTrue(group == CardSet(h5))