diff options
author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2011-08-13 13:22:40 (GMT) |
---|---|---|
committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2011-08-13 13:22:40 (GMT) |
commit | 1c38546e49e3f4bd53c0d470bcaaa9fb2f823401 (patch) | |
tree | 855b2bd6790b87283764b7043ed09ea6efa84d38 /Lib | |
parent | 74b6abf61f88221c4c859623a75655dcb214e072 (diff) | |
download | cpython-1c38546e49e3f4bd53c0d470bcaaa9fb2f823401.zip cpython-1c38546e49e3f4bd53c0d470bcaaa9fb2f823401.tar.gz cpython-1c38546e49e3f4bd53c0d470bcaaa9fb2f823401.tar.bz2 |
Issue #12646: Add an 'eof' attribute to zlib.Decompress.
This will make it easier to detect truncated input streams.
Also, make zlib's error messages more consistent.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_zlib.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 68dd3ea..dddde47 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -447,6 +447,26 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase): y += dco.flush() self.assertEqual(y, b'foo') + def test_decompress_eof(self): + x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E' # 'foo' + dco = zlib.decompressobj() + self.assertFalse(dco.eof) + dco.decompress(x[:-5]) + self.assertFalse(dco.eof) + dco.decompress(x[-5:]) + self.assertTrue(dco.eof) + dco.flush() + self.assertTrue(dco.eof) + + def test_decompress_eof_incomplete_stream(self): + x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E' # 'foo' + dco = zlib.decompressobj() + self.assertFalse(dco.eof) + dco.decompress(x[:-5]) + self.assertFalse(dco.eof) + dco.flush() + self.assertFalse(dco.eof) + if hasattr(zlib.compressobj(), "copy"): def test_compresscopy(self): # Test copying a compression object |