diff options
author | Zackery Spytz <zspytz@gmail.com> | 2019-05-13 07:50:52 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2019-05-13 07:50:52 (GMT) |
commit | cf599f6f6f1c392d8f12936982a370d533782195 (patch) | |
tree | da53ae10a41332d3e52c38cd3603c36dcb4329cd /Lib/test/test_gzip.py | |
parent | d28772ab6967fea136c0707f0207673ebad66f61 (diff) | |
download | cpython-cf599f6f6f1c392d8f12936982a370d533782195.zip cpython-cf599f6f6f1c392d8f12936982a370d533782195.tar.gz cpython-cf599f6f6f1c392d8f12936982a370d533782195.tar.bz2 |
bpo-6584: Add a BadGzipFile exception to the gzip module. (GH-13022)
Co-Authored-By: Filip Gruszczyński <gruszczy@gmail.com>
Co-Authored-By: Michele Orrù <maker@tumbolandia.net>
Diffstat (limited to 'Lib/test/test_gzip.py')
-rw-r--r-- | Lib/test/test_gzip.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 3583b47..48a36a3 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -391,6 +391,15 @@ class TestGzip(BaseTest): d = f.read() self.assertEqual(d, data1 * 50, "Incorrect data in file") + def test_gzip_BadGzipFile_exception(self): + self.assertTrue(issubclass(gzip.BadGzipFile, OSError)) + + def test_bad_gzip_file(self): + with open(self.filename, 'wb') as file: + file.write(data1 * 50) + with gzip.GzipFile(self.filename, 'r') as file: + self.assertRaises(gzip.BadGzipFile, file.readlines) + def test_non_seekable_file(self): uncompressed = data1 * 50 buf = UnseekableIO() |