コード例 #1
0
 def test_should_not_contain_non_element(self):
     rrs = RoundRobinSet([1, 2, 3])
     assert 4 not in rrs
コード例 #2
0
 def test_should_be_able_to_get_next_if_empty(self):
     rrs = RoundRobinSet([])
     assert next(rrs) is None
コード例 #3
0
 def test_should_be_able_to_replace(self):
     rrs = RoundRobinSet([1, 2, 3])
     rrs.replace([3, 4, 5])
     assert list(rrs) == [3, 4, 5]
コード例 #4
0
 def test_should_repr_as_set(self):
     rrs = RoundRobinSet([1, 2, 3])
     assert repr(rrs) == "{1, 2, 3}"
コード例 #5
0
 def test_should_not_be_able_to_remove_non_existing(self):
     rrs = RoundRobinSet([1, 2, 3])
     with self.assertRaises(ValueError):
         rrs.remove(4)
コード例 #6
0
 def test_should_be_able_to_update(self):
     rrs = RoundRobinSet([1, 2, 3])
     rrs.update([3, 4, 5])
     assert list(rrs) == [1, 2, 3, 4, 5]
コード例 #7
0
 def test_should_be_able_to_discard_non_existing(self):
     rrs = RoundRobinSet([1, 2, 3])
     rrs.discard(4)
     assert list(rrs) == [1, 2, 3]
コード例 #8
0
 def test_should_be_able_to_remove_existing(self):
     rrs = RoundRobinSet([1, 2, 3])
     rrs.remove(2)
     assert list(rrs) == [1, 3]
コード例 #9
0
 def test_should_be_able_to_add_existing(self):
     rrs = RoundRobinSet([1, 2, 3])
     rrs.add(2)
     assert list(rrs) == [1, 2, 3]
コード例 #10
0
 def test_should_be_able_to_clear(self):
     rrs = RoundRobinSet([1, 2, 3])
     rrs.clear()
     assert list(rrs) == []
コード例 #11
0
 def test_should_be_able_to_add_new(self):
     rrs = RoundRobinSet([1, 2, 3])
     rrs.add(4)
     assert list(rrs) == [1, 2, 3, 4]
コード例 #12
0
 def test_should_have_length(self):
     rrs = RoundRobinSet([1, 2, 3])
     assert len(rrs) == 3
コード例 #13
0
 def test_should_be_iterable(self):
     rrs = RoundRobinSet([1, 2, 3])
     assert list(iter(rrs)) == [1, 2, 3]
コード例 #14
0
 def test_should_be_able_to_get_next_repeatedly_via_old_method(self):
     rrs = RoundRobinSet([1, 2, 3])
     assert rrs.next() == 1
     assert rrs.next() == 2
     assert rrs.next() == 3
     assert rrs.next() == 1
コード例 #15
0
 def test_should_be_able_to_get_next_repeatedly(self):
     rrs = RoundRobinSet([1, 2, 3])
     assert next(rrs) == 1
     assert next(rrs) == 2
     assert next(rrs) == 3
     assert next(rrs) == 1