Example #1
0
 def test_should_be_able_to_update(self):
     s = OrderedSet([1, 2, 3])
     s.update([3, 4, 5])
     assert list(s) == [1, 2, 3, 4, 5]
Example #2
0
 def test_should_be_able_to_replace(self):
     s = OrderedSet([1, 2, 3])
     s.replace([3, 4, 5])
     assert list(s) == [3, 4, 5]
Example #3
0
 def test_should_be_able_to_remove_existing(self):
     s = OrderedSet([1, 2, 3])
     s.remove(2)
     assert list(s) == [1, 3]
Example #4
0
 def test_should_not_be_able_to_remove_non_existing(self):
     s = OrderedSet([1, 2, 3])
     with self.assertRaises(ValueError):
         s.remove(4)
Example #5
0
 def test_should_be_able_to_clear(self):
     s = OrderedSet([1, 2, 3])
     s.clear()
     assert list(s) == []
Example #6
0
 def test_should_be_able_to_discard_non_existing(self):
     s = OrderedSet([1, 2, 3])
     s.discard(4)
     assert list(s) == [1, 2, 3]
Example #7
0
 def test_should_be_able_to_add_new(self):
     s = OrderedSet([1, 2, 3])
     s.add(4)
     assert list(s) == [1, 2, 3, 4]
Example #8
0
 def test_should_be_able_to_add_existing(self):
     s = OrderedSet([1, 2, 3])
     s.add(2)
     assert list(s) == [1, 2, 3]
Example #9
0
 def test_should_be_iterable(self):
     s = OrderedSet([1, 2, 3])
     assert list(iter(s)) == [1, 2, 3]
Example #10
0
 def test_should_have_length(self):
     s = OrderedSet([1, 2, 3])
     assert len(s) == 3
Example #11
0
 def test_should_be_able_to_get_items_by_index(self):
     s = OrderedSet([1, 2, 3])
     self.assertEqual(s[0], 1)
     self.assertEqual(s[1], 2)
     self.assertEqual(s[2], 3)
Example #12
0
 def test_should_be_able_to_get_item_if_empty(self):
     s = OrderedSet([])
     with self.assertRaises(IndexError):
         _ = s[0]
Example #13
0
 def test_should_not_contain_non_element(self):
     s = OrderedSet([1, 2, 3])
     assert 4 not in s
Example #14
0
 def test_should_contain_element(self):
     s = OrderedSet([1, 2, 3])
     assert 2 in s
Example #15
0
 def test_should_repr_as_set(self):
     s = OrderedSet([1, 2, 3])
     assert repr(s) == "{1, 2, 3}"