summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bz2.py
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2011-05-30 00:09:54 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2011-05-30 00:09:54 (GMT)
commit72e58651b27e8b0a8f4170531ca6e985d9947d1b (patch)
tree9564a9430c4007662ba5821eaab53fab16659a6e /Lib/test/test_bz2.py
parentf3ecb8382222577ce9aef9901b91c9ba69a41f32 (diff)
downloadcpython-72e58651b27e8b0a8f4170531ca6e985d9947d1b.zip
cpython-72e58651b27e8b0a8f4170531ca6e985d9947d1b.tar.gz
cpython-72e58651b27e8b0a8f4170531ca6e985d9947d1b.tar.bz2
Simplify line-oriented tests in test_bz2.
Diffstat (limited to 'Lib/test/test_bz2.py')
-rw-r--r--Lib/test/test_bz2.py21
1 files changed, 7 insertions, 14 deletions
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index e2c34d5..75078be 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -163,43 +163,37 @@ class BZ2FileTest(BaseTest):
self.createTempFile()
with BZ2File(self.filename) as bz2f:
self.assertRaises(TypeError, bz2f.readline, None)
- sio = BytesIO(self.TEXT)
- for line in sio.readlines():
+ for line in self.TEXT_LINES:
self.assertEqual(bz2f.readline(), line)
def testReadLineMultiStream(self):
self.createTempFile(streams=5)
with BZ2File(self.filename) as bz2f:
self.assertRaises(TypeError, bz2f.readline, None)
- sio = BytesIO(self.TEXT * 5)
- for line in sio.readlines():
+ for line in self.TEXT_LINES * 5:
self.assertEqual(bz2f.readline(), line)
def testReadLines(self):
self.createTempFile()
with BZ2File(self.filename) as bz2f:
self.assertRaises(TypeError, bz2f.readlines, None)
- sio = BytesIO(self.TEXT)
- self.assertEqual(bz2f.readlines(), sio.readlines())
+ self.assertEqual(bz2f.readlines(), self.TEXT_LINES)
def testReadLinesMultiStream(self):
self.createTempFile(streams=5)
with BZ2File(self.filename) as bz2f:
self.assertRaises(TypeError, bz2f.readlines, None)
- sio = BytesIO(self.TEXT * 5)
- self.assertEqual(bz2f.readlines(), sio.readlines())
+ self.assertEqual(bz2f.readlines(), self.TEXT_LINES * 5)
def testIterator(self):
self.createTempFile()
with BZ2File(self.filename) as bz2f:
- sio = BytesIO(self.TEXT)
- self.assertEqual(list(iter(bz2f)), sio.readlines())
+ self.assertEqual(list(iter(bz2f)), self.TEXT_LINES)
def testIteratorMultiStream(self):
self.createTempFile(streams=5)
with BZ2File(self.filename) as bz2f:
- sio = BytesIO(self.TEXT * 5)
- self.assertEqual(list(iter(bz2f)), sio.readlines())
+ self.assertEqual(list(iter(bz2f)), self.TEXT_LINES * 5)
def testClosedIteratorDeadlock(self):
# Issue #3309: Iteration on a closed BZ2File should release the lock.
@@ -233,8 +227,7 @@ class BZ2FileTest(BaseTest):
def testWriteLines(self):
with BZ2File(self.filename, "w") as bz2f:
self.assertRaises(TypeError, bz2f.writelines)
- sio = BytesIO(self.TEXT)
- bz2f.writelines(sio.readlines())
+ bz2f.writelines(self.TEXT_LINES)
# Issue #1535500: Calling writelines() on a closed BZ2File
# should raise an exception.
self.assertRaises(ValueError, bz2f.writelines, ["a"])