當前位置: 首頁>>代碼示例>>Python>>正文


Python CircularBuffer.read方法代碼示例

本文整理匯總了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()
開發者ID:ozan,項目名稱:solutions,代碼行數:10,代碼來源:circular_buffer_test.py

示例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()
開發者ID:ozan,項目名稱:solutions,代碼行數:10,代碼來源:circular_buffer_test.py

示例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())
開發者ID:ozan,項目名稱:solutions,代碼行數:10,代碼來源:circular_buffer_test.py

示例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')
開發者ID:ThomasZumsteg,項目名稱:exercism-python,代碼行數:13,代碼來源:circular_buffer_test.py

示例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())
開發者ID:ozan,項目名稱:solutions,代碼行數:14,代碼來源:circular_buffer_test.py

示例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')
開發者ID:ThomasZumsteg,項目名稱:exercism-python,代碼行數:9,代碼來源:circular_buffer_test.py

示例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()
開發者ID:ozan,項目名稱:solutions,代碼行數:21,代碼來源:circular_buffer_test.py

示例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()
開發者ID:ozan,項目名稱:solutions,代碼行數:6,代碼來源:circular_buffer_test.py

示例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())
開發者ID:ozan,項目名稱:solutions,代碼行數:8,代碼來源:circular_buffer_test.py

示例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()
開發者ID:ozan,項目名稱:solutions,代碼行數:8,代碼來源:circular_buffer_test.py

示例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')
開發者ID:ThomasZumsteg,項目名稱:exercism-python,代碼行數:8,代碼來源:circular_buffer_test.py

示例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')
開發者ID:ThomasZumsteg,項目名稱:exercism-python,代碼行數:7,代碼來源:circular_buffer_test.py

示例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')
開發者ID:ThomasZumsteg,項目名稱:exercism-python,代碼行數:8,代碼來源:circular_buffer_test.py

示例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()
開發者ID:ThomasZumsteg,項目名稱:exercism-python,代碼行數:8,代碼來源:circular_buffer_test.py

示例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')
開發者ID:ThomasZumsteg,項目名稱:exercism-python,代碼行數:8,代碼來源:circular_buffer_test.py


注:本文中的circular_buffer.CircularBuffer.read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。