本文整理汇总了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)
示例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())
示例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())
示例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)
示例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()
示例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'])
示例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)
示例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()
示例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()