def testLineBuffering(self):
"""
Test creating a LineBuffer and feeding it some lines. The lines should
build up in its internal buffer for a while and then get spat out to
the writer.
"""
output = []
input = iter(itertools.cycle(['012', '345', '6', '7', '8', '9']))
c = pop3._IteratorBuffer(output.extend, input, 6)
i = iter(c)
self.assertEquals(output, []) # nothing is buffer
i.next()
self.assertEquals(output, []) # '012' is buffered
i.next()
self.assertEquals(output, []) # '012345' is buffered
i.next()
self.assertEquals(output, ['012', '345', '6']) # nothing is buffered
for n in range(5):
i.next()
self.assertEquals(output, ['012', '345', '6', '7', '8', '9', '012', '345'])
评论列表
文章目录