本文整理匯總了Python中circular_buffer.CircularBuffer.clear方法的典型用法代碼示例。如果您正苦於以下問題:Python CircularBuffer.clear方法的具體用法?Python CircularBuffer.clear怎麽用?Python CircularBuffer.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類circular_buffer.CircularBuffer
的用法示例。
在下文中一共展示了CircularBuffer.clear方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_clearing_buffer
# 需要導入模塊: from circular_buffer import CircularBuffer [as 別名]
# 或者: from circular_buffer.CircularBuffer import clear [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())
示例2: test_clear_free_buffer_for_write
# 需要導入模塊: from circular_buffer import CircularBuffer [as 別名]
# 或者: from circular_buffer.CircularBuffer import clear [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')
示例3: test_clear_does_nothing_on_empty_buffer
# 需要導入模塊: from circular_buffer import CircularBuffer [as 別名]
# 或者: from circular_buffer.CircularBuffer import clear [as 別名]
def test_clear_does_nothing_on_empty_buffer(self):
buf = CircularBuffer(1)
buf.clear()
buf.write('1')
self.assertEqual(buf.read(), '1')
示例4: test_clearing_buffer
# 需要導入模塊: from circular_buffer import CircularBuffer [as 別名]
# 或者: from circular_buffer.CircularBuffer import clear [as 別名]
def test_clearing_buffer(self):
buf = CircularBuffer(1)
buf.write('1')
buf.clear()
with self.assertRaisesWithMessage(BufferEmptyException):
buf.read()