Beispiel #1
0
 def test_should_not_contain_non_element(self):
     s = OrderedSet([1, 2, 3])
     assert 4 not in s
Beispiel #2
0
 def test_should_be_able_to_get_item_if_empty(self):
     s = OrderedSet([])
     with self.assertRaises(IndexError):
         _ = s[0]
Beispiel #3
0
 def test_should_repr_as_set(self):
     s = OrderedSet([1, 2, 3])
     assert repr(s) == "{1, 2, 3}"
Beispiel #4
0
 def test_should_contain_element(self):
     s = OrderedSet([1, 2, 3])
     assert 2 in s
Beispiel #5
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]
Beispiel #6
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]
Beispiel #7
0
 def test_should_be_able_to_remove_existing(self):
     s = OrderedSet([1, 2, 3])
     s.remove(2)
     assert list(s) == [1, 3]
Beispiel #8
0
 def test_should_not_be_able_to_remove_non_existing(self):
     s = OrderedSet([1, 2, 3])
     with self.assertRaises(ValueError):
         s.remove(4)
Beispiel #9
0
 def test_should_be_able_to_clear(self):
     s = OrderedSet([1, 2, 3])
     s.clear()
     assert list(s) == []
Beispiel #10
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]
Beispiel #11
0
 def test_should_be_able_to_add_existing(self):
     s = OrderedSet([1, 2, 3])
     s.add(2)
     assert list(s) == [1, 2, 3]
Beispiel #12
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]
Beispiel #13
0
 def test_should_have_length(self):
     s = OrderedSet([1, 2, 3])
     assert len(s) == 3
Beispiel #14
0
 def test_should_be_iterable(self):
     s = OrderedSet([1, 2, 3])
     assert list(iter(s)) == [1, 2, 3]
Beispiel #15
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)