Exemplo n.º 1
0
class TestSortedSetRemove(unittest.TestCase):
    def setUp(self):
        self.ss = SortedSet([7, 3, 12, 8])

    def test_remove_an_existing_elem(self):
        oldlen = len(self.ss)
        self.ss.remove(7)
        self.assertEqual(len(self.ss), oldlen - 1)

    def test_remove_an_elem_that_is_not_in_the_set(self):
        self.assertRaises(KeyError, self.ss.remove, 53153)
Exemplo n.º 2
0
class TestSortedSetAdd(unittest.TestCase):
    def setUp(self):
        self.ss = SortedSet()

    def test_add(self):
        self.ss.add(3)
        self.assertEqual(len(self.ss), 1)

    def test_add_with_an_elem_already_in_the_set(self):
        self.ss.add(3)
        self.ss.add(3)
        self.assertEqual(len(self.ss), 1)

    @unittest.skipIf(PY2, "comparing different types is ok in PY2")
    def test_raise_unorderable_types(self):
        self.ss.add(3)
        self.assertRaises(TypeError, self.ss.add, 'sepeth')
Exemplo n.º 3
0
 def test_for_different_elements(self):
     s1 = SortedSet([3, 5, 7])
     s2 = SortedSet([3, 6, 7, 8])
     self.assertFalse(s1.issubset(s2))
Exemplo n.º 4
0
 def test_empty_set_issubset_of_everyset(self):
     e = SortedSet()
     s = SortedSet([7, 3, 5])
     self.assertTrue(e.issubset(s))
Exemplo n.º 5
0
 def test_smaller_set_scattered_throughout_longer_set(self):
     odds = SortedSet(range(1, 11, 2))
     numbers = SortedSet(range(0, 11))
     self.assertTrue(odds.issubset(numbers))
Exemplo n.º 6
0
 def test_same_sets_should_be_subset_eachother(self):
     s1 = SortedSet([7, 3, 5])
     s2 = SortedSet([5, 7, 3])
     self.assertTrue(s1.issubset(s2))
     self.assertTrue(s2.issubset(s1))
Exemplo n.º 7
0
 def test_set_is_subset_of_itself(self):
     s = SortedSet([5, 3, 7])
     self.assertTrue(s.issubset(s))
Exemplo n.º 8
0
 def test_longer_set_cannot_be_subset(self):
     longer = SortedSet([7, 3, 5])
     smaller = SortedSet([3, 5])
     self.assertFalse(longer.issubset(smaller))
Exemplo n.º 9
0
 def setUp(self):
     self.ss = SortedSet([7, 3, 12, 8])
Exemplo n.º 10
0
 def setUp(self):
     self.ss = SortedSet()
Exemplo n.º 11
0
 def test_issubset_with_a_list(self):
     s = SortedSet([3, 5, 7])
     l = [3, 5, 7, 9]
     self.assertTrue(s.issubset(l))