Esempio n. 1
0
 def test_pop_empty_no_default(self):
     b = Messagebuffer(10)
     with pytest.raises(b.Empty):
         b.take()
Esempio n. 2
0
 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()
Esempio n. 4
0
 def test_pop_empty_no_default(self):
     b = Messagebuffer(10)
     with pytest.raises(b.Empty):
         b.take()
Esempio n. 5
0
 def test_contains(self):
     b = Messagebuffer(10, list(range(10)))
     assert 5 in b
Esempio n. 6
0
 def test_extend_limited(self):
     b = Messagebuffer(10)
     b.extend(list(range(20)))
     self.assert_size_and_first(b, 10, 10)
Esempio n. 7
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
Esempio n. 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)
Esempio n. 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)
Esempio n. 15
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)
Esempio n. 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)
Esempio n. 17
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)
Esempio n. 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)
Esempio n. 19
0
 def test_extend_unlimited(self):
     b = Messagebuffer(None)
     b.extend(list(range(20)))
     self.assert_size_and_first(b, 20, 0)
Esempio n. 20
0
 def test_extend_limited(self):
     b = Messagebuffer(10)
     b.extend(list(range(20)))
     self.assert_size_and_first(b, 10, 10)
Esempio n. 21
0
 def test_pop_empty_with_default(self):
     b = Messagebuffer(10)
     sentinel = object()
     assert b.take(sentinel) is sentinel
Esempio n. 22
0
 def test_extend_unlimited(self):
     b = Messagebuffer(None)
     b.extend(list(range(20)))
     self.assert_size_and_first(b, 20, 0)
Esempio n. 23
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
Esempio n. 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
Esempio n. 25
0
 def test_reversed(self):
     assert (list(reversed(Messagebuffer(10, list(range(10))))) == list(
         reversed(range(10))))
Esempio n. 26
0
 def test_pop_empty_with_default(self):
     b = Messagebuffer(10)
     sentinel = object()
     assert b.take(sentinel) is sentinel
Esempio n. 27
0
 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)