本文整理汇总了Python中circular_buffer.CircularBuffer.read方法的典型用法代码示例。如果您正苦于以下问题:Python CircularBuffer.read方法的具体用法?Python CircularBuffer.read怎么用?Python CircularBuffer.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circular_buffer.CircularBuffer
的用法示例。
在下文中一共展示了CircularBuffer.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_overwrite_non_full_buffer
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_overwrite_non_full_buffer(self):
buf = CircularBuffer(2)
buf.overwrite('1')
buf.overwrite('2')
self.assertEqual('1', buf.read())
self.assertEqual('2', buf.read())
with self.assertRaises(BufferEmptyException):
buf.read()
示例2: test_write_and_read_back_multiple_items
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_write_and_read_back_multiple_items(self):
buf = CircularBuffer(2)
buf.write('1')
buf.write('2')
self.assertEqual('1', buf.read())
self.assertEqual('2', buf.read())
with self.assertRaises(BufferEmptyException):
buf.read()
示例3: test_read_back_oldest_item
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_read_back_oldest_item(self):
buf = CircularBuffer(3)
buf.write('1')
buf.write('2')
buf.read()
buf.write('3')
buf.read()
self.assertEqual('3', buf.read())
示例4: test_overwrite_replaces_oldest_remaining_item
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_overwrite_replaces_oldest_remaining_item(self):
buf = CircularBuffer(3)
buf.write('1')
buf.write('2')
buf.write('3')
self.assertEqual(buf.read(), '1')
buf.write('4')
buf.overwrite('5')
self.assertEqual(buf.read(), '3')
self.assertEqual(buf.read(), '4')
self.assertEqual(buf.read(), '5')
示例5: test_clearing_buffer
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_clearing_buffer(self):
buf = CircularBuffer(3)
for c in '123':
buf.write(c)
buf.clear()
with self.assertRaises(BufferEmptyException):
buf.read()
buf.write('1')
buf.write('2')
self.assertEqual('1', buf.read())
buf.write('3')
self.assertEqual('2', buf.read())
示例6: test_overwrite_replaces_oldest_item
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_overwrite_replaces_oldest_item(self):
buf = CircularBuffer(2)
buf.write('1')
buf.write('2')
buf.overwrite('3')
self.assertEqual(buf.read(), '2')
self.assertEqual(buf.read(), '3')
示例7: test_alternate_read_and_overwrite
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_alternate_read_and_overwrite(self):
buf = CircularBuffer(5)
for c in '123':
buf.write(c)
buf.read()
buf.read()
buf.write('4')
buf.read()
for c in '5678':
buf.write(c)
buf.overwrite('A')
buf.overwrite('B')
self.assertEqual('6', buf.read())
self.assertEqual('7', buf.read())
self.assertEqual('8', buf.read())
self.assertEqual('A', buf.read())
self.assertEqual('B', buf.read())
with self.assertRaises(BufferEmptyException):
buf.read()
示例8: test_read_empty_buffer
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_read_empty_buffer(self):
buf = CircularBuffer(1)
with self.assertRaises(BufferEmptyException):
buf.read()
示例9: test_alternate_write_and_read
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_alternate_write_and_read(self):
buf = CircularBuffer(2)
buf.write('1')
self.assertEqual('1', buf.read())
buf.write('2')
self.assertEqual('2', buf.read())
示例10: test_write_and_read_back_one_item
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_write_and_read_back_one_item(self):
buf = CircularBuffer(1)
buf.write('1')
self.assertEqual('1', buf.read())
with self.assertRaises(BufferEmptyException):
buf.read()
示例11: test_overwrite_non_full_buffer
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_overwrite_non_full_buffer(self):
buf = CircularBuffer(2)
buf.write('1')
buf.overwrite('2')
self.assertEqual(buf.read(), '1')
self.assertEqual(buf.read(), '2')
示例12: test_clear_does_nothing_on_empty_buffer
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_clear_does_nothing_on_empty_buffer(self):
buf = CircularBuffer(1)
buf.clear()
buf.write('1')
self.assertEqual(buf.read(), '1')
示例13: test_clear_free_buffer_for_write
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_clear_free_buffer_for_write(self):
buf = CircularBuffer(1)
buf.write('1')
buf.clear()
buf.write('2')
self.assertEqual(buf.read(), '2')
示例14: test_clearing_buffer
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_clearing_buffer(self):
buf = CircularBuffer(1)
buf.write('1')
buf.clear()
with self.assertRaisesWithMessage(BufferEmptyException):
buf.read()
示例15: test_write_and_read_back_multiple_items_ordered
# 需要导入模块: from circular_buffer import CircularBuffer [as 别名]
# 或者: from circular_buffer.CircularBuffer import read [as 别名]
def test_write_and_read_back_multiple_items_ordered(self):
buf = CircularBuffer(2)
buf.write('1')
buf.write('2')
self.assertEqual(buf.read(), '1')
self.assertEqual(buf.read(), '2')