diff options
author | Ruben Vorderman <r.h.p.vorderman@lumc.nl> | 2022-05-03 05:11:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 05:11:06 (GMT) |
commit | a73fc73ff7586b09d68a330760d06862f5bafb9b (patch) | |
tree | 212dd417aa8e895fdb79f61675ebbbc57d1dab7c /Lib | |
parent | e846fe3fc189ff54413382611ee36e41c2f0776b (diff) | |
download | cpython-a73fc73ff7586b09d68a330760d06862f5bafb9b.zip cpython-a73fc73ff7586b09d68a330760d06862f5bafb9b.tar.gz cpython-a73fc73ff7586b09d68a330760d06862f5bafb9b.tar.bz2 |
bpo-46267: Test compresslevel in gzip.compress (#30416)
Fixes #90425
Diffstat (limited to 'Lib')
-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 497e66c..6de413e 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -552,6 +552,15 @@ class TestGzip(BaseTest): f.read(1) # to set mtime attribute self.assertEqual(f.mtime, mtime) + def test_compress_correct_level(self): + # gzip.compress calls with mtime == 0 take a different code path. + for mtime in (0, 42): + with self.subTest(mtime=mtime): + nocompress = gzip.compress(data1, compresslevel=0, mtime=mtime) + yescompress = gzip.compress(data1, compresslevel=1, mtime=mtime) + self.assertIn(data1, nocompress) + self.assertNotIn(data1, yescompress) + def test_decompress(self): for data in (data1, data2): buf = io.BytesIO() |