summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bz2.py
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2011-09-11 20:38:11 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2011-09-11 20:38:11 (GMT)
commit249ab5e8d1452ab7bc43b0f1e1221e0065d2e52d (patch)
tree6ebff12b415d2245e019902ec858a4b946098282 /Lib/test/test_bz2.py
parentc92f6226d7e83a93a8ab535d3e964ae50c2c5272 (diff)
downloadcpython-249ab5e8d1452ab7bc43b0f1e1221e0065d2e52d.zip
cpython-249ab5e8d1452ab7bc43b0f1e1221e0065d2e52d.tar.gz
cpython-249ab5e8d1452ab7bc43b0f1e1221e0065d2e52d.tar.bz2
BZ2File now uses the compresslevel argument given by the caller,
instead of ignoring it and always using a compression level of 9.
Diffstat (limited to 'Lib/test/test_bz2.py')
-rw-r--r--Lib/test/test_bz2.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index 5a7d342..d003238 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -224,6 +224,13 @@ class BZ2FileTest(BaseTest):
with open(self.filename, 'rb') as f:
self.assertEqual(self.decompress(f.read()), self.TEXT)
+ def testWriteNonDefaultCompressLevel(self):
+ expected = bz2.compress(self.TEXT, compresslevel=5)
+ with BZ2File(self.filename, "w", compresslevel=5) as bz2f:
+ bz2f.write(self.TEXT)
+ with open(self.filename, "rb") as f:
+ self.assertEqual(f.read(), expected)
+
def testWriteLines(self):
with BZ2File(self.filename, "w") as bz2f:
self.assertRaises(TypeError, bz2f.writelines)