예제 #1
0
 def test_contains(self):
     h3 = Card('h3')
     h4 = Card('h4')
     h5 = Card('h5')
     h6 = Card('h6')
     child_group = CardSet([h3, h4, h5])
     parent_group = CardSet([h3, h4, h5, h6])
     self.assertTrue(parent_group.contains(child_group))
     self.assertTrue(child_group.isin(parent_group))
     self.assertFalse(child_group.contains(parent_group))
     self.assertTrue(child_group.contains(h3))
     self.assertTrue(child_group.contains(CardSet(h3)))
예제 #2
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]))
예제 #3
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))