当前位置: 首页>>代码示例>>Python>>正文


Python BZ2File.readlines方法代码示例

本文整理汇总了Python中bz2.BZ2File.readlines方法的典型用法代码示例。如果您正苦于以下问题:Python BZ2File.readlines方法的具体用法?Python BZ2File.readlines怎么用?Python BZ2File.readlines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bz2.BZ2File的用法示例。


在下文中一共展示了BZ2File.readlines方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testReadLine

# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readlines [as 别名]
def testReadLine(self):
        # "Test BZ2File.readline()"
        self.createTempFile()
        with BZ2File(self.filename) as bz2f:
            self.assertRaises(TypeError, bz2f.readline, None)
            sio = StringIO(self.TEXT)
            for line in sio.readlines():
                self.assertEqual(bz2f.readline(), line) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_bz2.py

示例2: testReadLines

# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readlines [as 别名]
def testReadLines(self):
        # "Test BZ2File.readlines()"
        self.createTempFile()
        with BZ2File(self.filename) as bz2f:
            self.assertRaises(TypeError, bz2f.readlines, None)
            sio = StringIO(self.TEXT)
            self.assertEqual(bz2f.readlines(), sio.readlines()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_bz2.py

示例3: testIterator

# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readlines [as 别名]
def testIterator(self):
        # "Test iter(BZ2File)"
        self.createTempFile()
        with BZ2File(self.filename) as bz2f:
            sio = StringIO(self.TEXT)
            self.assertEqual(list(iter(bz2f)), sio.readlines()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_bz2.py

示例4: testClosedIteratorDeadlock

# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readlines [as 别名]
def testClosedIteratorDeadlock(self):
        # "Test that iteration on a closed bz2file releases the lock."
        # http://bugs.python.org/issue3309
        self.createTempFile()
        bz2f = BZ2File(self.filename)
        bz2f.close()
        self.assertRaises(ValueError, bz2f.next)
        # This call will deadlock of the above .next call failed to
        # release the lock.
        self.assertRaises(ValueError, bz2f.readlines) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_bz2.py

示例5: testXReadLines

# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readlines [as 别名]
def testXReadLines(self):
        # "Test BZ2File.xreadlines()"
        self.createTempFile()
        bz2f = BZ2File(self.filename)
        sio = StringIO(self.TEXT)
        self.assertEqual(list(bz2f.xreadlines()), sio.readlines())
        bz2f.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_bz2.py

示例6: testBug1191043

# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readlines [as 别名]
def testBug1191043(self):
        # readlines() for files containing no newline
        data = 'BZh91AY&SY\xd9b\x89]\x00\x00\x00\x03\x80\x04\x00\x02\x00\x0c\x00 \x00!\x9ah3M\x13<]\xc9\x14\xe1BCe\x8a%t'
        with open(self.filename, "wb") as f:
            f.write(data)
        with BZ2File(self.filename) as bz2f:
            lines = bz2f.readlines()
        self.assertEqual(lines, ['Test'])
        with BZ2File(self.filename) as bz2f:
            xlines = list(bz2f.readlines())
        self.assertEqual(xlines, ['Test']) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_bz2.py

示例7: testMixedIterationReads

# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readlines [as 别名]
def testMixedIterationReads(self):
        # Issue #8397: mixed iteration and reads should be forbidden.
        with bz2.BZ2File(self.filename, 'wb') as f:
            # The internal buffer size is hard-wired to 8192 bytes, we must
            # write out more than that for the test to stop half through
            # the buffer.
            f.write(self.TEXT * 100)
        with bz2.BZ2File(self.filename, 'rb') as f:
            next(f)
            self.assertRaises(ValueError, f.read)
            self.assertRaises(ValueError, f.readline)
            self.assertRaises(ValueError, f.readlines) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_bz2.py

示例8: testReadLine

# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readlines [as 别名]
def testReadLine(self):
        # "Test BZ2File.readline()"
        self.createTempFile()
        bz2f = BZ2File(self.filename)
        self.assertRaises(TypeError, bz2f.readline, None)
        sio = StringIO(self.TEXT)
        for line in sio.readlines():
            self.assertEqual(bz2f.readline(), line)
        bz2f.close() 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:11,代码来源:test_bz2.py

示例9: testReadLines

# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readlines [as 别名]
def testReadLines(self):
        # "Test BZ2File.readlines()"
        self.createTempFile()
        bz2f = BZ2File(self.filename)
        self.assertRaises(TypeError, bz2f.readlines, None)
        sio = StringIO(self.TEXT)
        self.assertEqual(bz2f.readlines(), sio.readlines())
        bz2f.close() 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:10,代码来源:test_bz2.py


注:本文中的bz2.BZ2File.readlines方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。