Example #1
0
 def test_chunkedread_on_fileobject(self):
     fo = StringIO('one\nbig\nchunk\nof\ndata\n')
     chunks = chunkedread(fo, chunksize=10)
     self.assertEqual(chunks.next(), 'one\nbig\nch')
     self.assertEqual(chunks.next(), 'unk\nof\ndat')
     self.assertEqual(chunks.next(), 'a\n')
     self.assertRaises(StopIteration, chunks.next)
     fo.close()
Example #2
0
 def test_chunkedread_on_fileobject(self):
     fo = StringIO('one\nbig\nchunk\nof\ndata\n')
     chunks = chunkedread(fo, chunksize=10)
     self.assertEqual(chunks.next(), 'one\nbig\nch')
     self.assertEqual(chunks.next(), 'unk\nof\ndat')
     self.assertEqual(chunks.next(), 'a\n')
     self.assertRaises(StopIteration, chunks.next)
     fo.close()
Example #3
0
 def test_chunkedread_on_filename(self):
     fn = mkstemp()[1]
     try:
         fo = open(fn, 'wb')
         fo.write('one\nbig\nchunk\nof\ndata\n')
         fo.close()
         chunks = chunkedread(fn, chunksize=10)
         self.assertEqual(chunks.next(), 'one\nbig\nch')
         self.assertEqual(chunks.next(), 'unk\nof\ndat')
         self.assertEqual(chunks.next(), 'a\n')
         self.assertRaises(StopIteration, chunks.next)
     finally:
         os.unlink(fn)
Example #4
0
 def test_chunkedread_on_filename(self):
     fn = mkstemp()[1]
     try:
         fo = open(fn, 'wb')
         fo.write('one\nbig\nchunk\nof\ndata\n')
         fo.close()
         chunks = chunkedread(fn, chunksize=10)
         self.assertEqual(chunks.next(), 'one\nbig\nch')
         self.assertEqual(chunks.next(), 'unk\nof\ndat')
         self.assertEqual(chunks.next(), 'a\n')
         self.assertRaises(StopIteration, chunks.next)
     finally:
         os.unlink(fn)