MCPcopy Index your code
hub / github.com/python/cpython / testReadlinesNoNewline

Method testReadlinesNoNewline

Lib/test/test_bz2.py:476–486  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

474 self.assertRaises(OSError, BZ2File, "/non/existent")
475
476 def testReadlinesNoNewline(self):
477 # Issue #1191043: readlines() fails on a file containing no newline.
478 data = b'BZh91AY&SY\xd9b\x89]\x00\x00\x00\x03\x80\x04\x00\x02\x00\x0c\x00 \x00!\x9ah3M\x13<]\xc9\x14\xe1BCe\x8a%t'
479 with open(self.filename, "wb") as f:
480 f.write(data)
481 with BZ2File(self.filename) as bz2f:
482 lines = bz2f.readlines()
483 self.assertEqual(lines, [b'Test'])
484 with BZ2File(self.filename) as bz2f:
485 xlines = list(bz2f.readlines())
486 self.assertEqual(xlines, [b'Test'])
487
488 def testContextProtocol(self):
489 with BZ2File(self.filename, "wb") as f:

Callers

nothing calls this directly

Calls 6

BZ2FileClass · 0.90
listClass · 0.85
openFunction · 0.50
writeMethod · 0.45
readlinesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected