diff -r 2f0716009132 Lib/test/test_gzip.py --- a/Lib/test/test_gzip.py Tue Jul 12 18:24:25 2016 -0400 +++ b/Lib/test/test_gzip.py Fri Jul 15 22:26:57 2016 +0300 @@ -619,6 +619,23 @@ with gzip.open(self.filename, "rt", newline="\r") as f: self.assertEqual(f.readlines(), [uncompressed]) + def test_compress_level(self): + # Test the compress level header, trying all the options. + uncompressed = data1 * 50 + expected_xfl = [b'\x00']*10 + expected_xfl[1] = b'\x04' + expected_xfl[9] = b'\x02' + + for cl in range(10): + with gzip.open(self.filename, "w", compresslevel=cl) as f: + f.write(uncompressed) + with open(self.filename, "rb") as f: + f.seek(8) + xfl_byte = f.read(1) + print(cl, xfl_byte, expected_xfl[cl]) + self.assertEqual(xfl_byte, expected_xfl[cl]) + + def test_main(verbose=None): support.run_unittest(TestGzip, TestOpen)