def testMixedIterationAndReads(self):
    self.createTempFile()
    linelen = len(self.TEXT_LINES[0])
    halflen = (linelen // 2)
    with BZ2File(self.filename) as bz2f:
        bz2f.read(halflen)
        self.assertEqual(next(bz2f), self.TEXT_LINES[0][halflen:])
        self.assertEqual(bz2f.read(), self.TEXT[linelen:])
    with BZ2File(self.filename) as bz2f:
        bz2f.readline()
        self.assertEqual(next(bz2f), self.TEXT_LINES[1])
        self.assertEqual(bz2f.readline(), self.TEXT_LINES[2])
    with BZ2File(self.filename) as bz2f:
        bz2f.readlines()
        self.assertRaises(StopIteration, next, bz2f)
        self.assertEqual(bz2f.readlines(), [])
def testMixedIterationAndReads(self):
    self.createTempFile()
    linelen = len(self.TEXT_LINES[0])
    halflen = (linelen // 2)
    with BZ2File(self.filename) as bz2f:
        bz2f.read(halflen)
        self.assertEqual(next(bz2f), self.TEXT_LINES[0][halflen:])
        self.assertEqual(bz2f.read(), self.TEXT[linelen:])
    with BZ2File(self.filename) as bz2f:
        bz2f.readline()
        self.assertEqual(next(bz2f), self.TEXT_LINES[1])
        self.assertEqual(bz2f.readline(), self.TEXT_LINES[2])
    with BZ2File(self.filename) as bz2f:
        bz2f.readlines()
        self.assertRaises(StopIteration, next, bz2f)
        self.assertEqual(bz2f.readlines(), [])