def test_pop_empty_no_default(self):
     b = Messagebuffer(10)
     with pytest.raises(b.Empty):
         b.take()
 def test_getitem(self):
     b = Messagebuffer(10, list(range(10)))
     for i in range(10):
         assert b[i] == i
 def test_pop_empty_no_default(self):
     b = Messagebuffer(10)
     with self.assertRaises(b.Empty):
         b.take()
 def test_pop_empty_no_default(self):
     b = Messagebuffer(10)
     with pytest.raises(b.Empty):
         b.take()
 def test_contains(self):
     b = Messagebuffer(10, list(range(10)))
     assert 5 in b
 def test_extend_limited(self):
     b = Messagebuffer(10)
     b.extend(list(range(20)))
     self.assert_size_and_first(b, 10, 10)
 def test_extend_eviction_time_limited(self):
     b = Messagebuffer(3000)
     b.extend(range(10000))
     assert len(b) > 3000
     b.evict()
     assert len(b) == 3000
Beispiel #8
0
 def test_extend_eviction_time_limited(self):
     b = Messagebuffer(3000)
     b.extend(range(10000))
     self.assertGreater(len(b), 3000)
     b.evict()
     self.assertEqual(len(b), 3000)
Beispiel #9
0
 def test_pop_empty_no_default(self):
     b = Messagebuffer(10)
     with self.assertRaises(b.Empty):
         b.take()
 def test_getitem(self):
     b = Messagebuffer(10, list(range(10)))
     for i in range(10):
         self.assertEqual(b[i], i)
 def test_repr(self):
     self.assertTrue(repr(Messagebuffer(10, [1, 2, 3])))
 def test_reversed(self):
     self.assertEqual(
         list(reversed(Messagebuffer(10, list(range(10))))),
         list(reversed(range(10))),
     )
 def test_contains(self):
     b = Messagebuffer(10, list(range(10)))
     self.assertIn(5, b)
 def test_iter(self):
     b = Messagebuffer(10, list(range(10)))
     self.assertEqual(len(b), 10)
     for i, item in enumerate(b):
         self.assertEqual(item, i)
     self.assertEqual(len(b), 0)
 def test_append_limited(self):
     b = Messagebuffer(10)
     for i in range(20):
         b.put(i)
     self.assert_size_and_first(b, 10, 10)
Beispiel #16
0
 def test_append_limited(self):
     b = Messagebuffer(10)
     for i in range(20):
         b.put(i)
     self.assert_size_and_first(b, 10, 10)
 def test_append_unlimited(self):
     b = Messagebuffer(None)
     for i in range(20):
         b.put(i)
     self.assert_size_and_first(b, 20, 0)
Beispiel #18
0
 def test_append_unlimited(self):
     b = Messagebuffer(None)
     for i in range(20):
         b.put(i)
     self.assert_size_and_first(b, 20, 0)
 def test_extend_unlimited(self):
     b = Messagebuffer(None)
     b.extend(list(range(20)))
     self.assert_size_and_first(b, 20, 0)
Beispiel #20
0
 def test_extend_limited(self):
     b = Messagebuffer(10)
     b.extend(list(range(20)))
     self.assert_size_and_first(b, 10, 10)
 def test_pop_empty_with_default(self):
     b = Messagebuffer(10)
     sentinel = object()
     assert b.take(sentinel) is sentinel
Beispiel #22
0
 def test_extend_unlimited(self):
     b = Messagebuffer(None)
     b.extend(list(range(20)))
     self.assert_size_and_first(b, 20, 0)
 def test_iter(self):
     b = Messagebuffer(10, list(range(10)))
     assert len(b) == 10
     for i, item in enumerate(b):
         assert item == i
     assert len(b) == 0
Beispiel #24
0
 def test_extend_eviction_time_limited(self):
     b = Messagebuffer(3000)
     b.extend(range(10000))
     assert len(b) > 3000
     b.evict()
     assert len(b) == 3000
 def test_reversed(self):
     assert (list(reversed(Messagebuffer(10, list(range(10))))) == list(
         reversed(range(10))))
Beispiel #26
0
 def test_pop_empty_with_default(self):
     b = Messagebuffer(10)
     sentinel = object()
     assert b.take(sentinel) is sentinel
 def test_repr(self):
     assert repr(Messagebuffer(10, [1, 2, 3]))
 def test_extend_eviction_time_limited(self):
     b = Messagebuffer(3000)
     b.extend(range(10000))
     self.assertGreater(len(b), 3000)
     b.evict()
     self.assertEqual(len(b), 3000)