Esempio n. 1
0
 def test_FinishLineBuffering(self):
     """
     Test that a LineBuffer flushes everything when its iterator is
     exhausted, and itself raises StopIteration.
     """
     output = []
     input = iter(["a", "b", "c"])
     c = pop3._IteratorBuffer(output.extend, input, 5)
     for i in c:
         pass
     self.assertEqual(output, ["a", "b", "c"])
Esempio n. 2
0
 def testFinishLineBuffering(self):
     """
     Test that a LineBuffer flushes everything when its iterator is
     exhausted, and itself raises StopIteration.
     """
     output = []
     input = iter(['a', 'b', 'c'])
     c = pop3._IteratorBuffer(output.extend, input, 5)
     for i in c:
         pass
     self.assertEqual(output, ['a', 'b', 'c'])
Esempio n. 3
0
 def test_LineBuffering(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.assertEqual(output, [])  # Nothing is buffer
     next(i)
     self.assertEqual(output, [])  # '012' is buffered
     next(i)
     self.assertEqual(output, [])  # '012345' is buffered
     next(i)
     self.assertEqual(output, ["012", "345", "6"])  # Nothing is buffered
     for n in range(5):
         next(i)
     self.assertEqual(output, ["012", "345", "6", "7", "8", "9", "012", "345"])
Esempio n. 4
0
 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.assertEqual(output, []) # nothing is buffer
     i.next()
     self.assertEqual(output, []) # '012' is buffered
     i.next()
     self.assertEqual(output, []) # '012345' is buffered
     i.next()
     self.assertEqual(output, ['012', '345', '6']) # nothing is buffered
     for n in range(5):
         i.next()
     self.assertEqual(output, ['012', '345', '6', '7', '8', '9', '012', '345'])
Esempio n. 5
0
 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.assertEqual(output, []) # nothing is buffer
     i.next()
     self.assertEqual(output, []) # '012' is buffered
     i.next()
     self.assertEqual(output, []) # '012345' is buffered
     i.next()
     self.assertEqual(output, ['012', '345', '6']) # nothing is buffered
     for n in range(5):
         i.next()
     self.assertEqual(output, ['012', '345', '6', '7', '8', '9', '012', '345'])