|
26 | 26 | import tempfile |
27 | 27 | import unittest |
28 | 28 | from subprocess import PIPE, Popen |
29 | | -from test import support |
30 | 29 | from test.support import _4G, bigmemtest |
31 | 30 | from test.support.script_helper import assert_python_failure, assert_python_ok |
32 | 31 |
|
@@ -408,8 +407,12 @@ def test_compresslevel_metadata(self): |
408 | 407 |
|
409 | 408 | for (name, level, expectedXflByte) in cases: |
410 | 409 | major, minor, _, _, _ = sys.version_info |
411 | | - if major == 3 and minor < 7 or major < 3: |
412 | | - # Specific xfl bytes introduced in 3.7 |
| 410 | + if not ("compresslevel" in |
| 411 | + gzip.GzipFile._write_gzip_header.__code__.co_varnames |
| 412 | + and hasattr(gzip, "_COMPRESS_LEVEL_FAST") |
| 413 | + and hasattr(gzip, "_COMPRESS_LEVEL_TRADEOFF")): |
| 414 | + # Specific xfl bytes introduced in 3.9 and backported to |
| 415 | + # earlier versions |
413 | 416 | expectedXflByte = b'\x02' |
414 | 417 | with self.subTest(name): |
415 | 418 | fWrite = igzip.IGzipFile(self.filename, 'w', |
@@ -804,15 +807,13 @@ def test_decompress_infile_outfile(self): |
804 | 807 |
|
805 | 808 | with igzip.open(igzipname, mode='wb') as fp: |
806 | 809 | fp.write(self.data) |
807 | | - rc, out, err = assert_python_ok('-m', 'isal.igzip', '-d', igzipname) |
| 810 | + sys.argv = ['', '-d', igzipname] |
| 811 | + igzip.main() |
808 | 812 |
|
809 | 813 | with open(os.path.join(TEMPDIR, "testigzip"), "rb") as gunziped: |
810 | 814 | self.assertEqual(gunziped.read(), self.data) |
811 | 815 |
|
812 | 816 | self.assertTrue(os.path.exists(igzipname)) |
813 | | - self.assertEqual(rc, 0) |
814 | | - self.assertEqual(out, b'') |
815 | | - self.assertEqual(err, b'') |
816 | 817 |
|
817 | 818 | def test_decompress_infile_outfile_error(self): |
818 | 819 | rc, out, err = assert_python_ok('-m', 'isal.igzip', '-d', |
@@ -882,11 +883,3 @@ def test_decompress_cannot_have_flags_compression(self): |
882 | 883 | b'-0/--fast', |
883 | 884 | err) |
884 | 885 | self.assertEqual(out, b'') |
885 | | - |
886 | | - |
887 | | -def test_main(verbose=None): |
888 | | - support.run_unittest(TestGzip, TestOpen, TestCommandLine) |
889 | | - |
890 | | - |
891 | | -if __name__ == "__main__": |
892 | | - test_main(verbose=True) |
0 commit comments