From 749e1c4b84c9fa49e8ccad0139d464d66cb3dc3b Mon Sep 17 00:00:00 2001 From: James Webber Date: Tue, 27 Jun 2023 14:34:37 -0400 Subject: [PATCH] remove more zlib checks --- Doc/library/test.rst | 5 ----- Lib/test/support/__init__.py | 9 +-------- Lib/test/test_shutil.py | 11 ----------- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/Doc/library/test.rst b/Doc/library/test.rst index 699db14596f250..8b00b65976cae3 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -702,11 +702,6 @@ The :mod:`test.support` module defines the following functions: Decorator for skipping tests on non-IEEE 754 platforms. -.. decorator:: requires_zlib - - Decorator for skipping tests if :mod:`zlib` doesn't exist. - - .. decorator:: requires_gzip Decorator for skipping tests if :mod:`gzip` doesn't exist. diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index fc1b86bebcd1ae..16ccca0cbedaf8 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -39,7 +39,7 @@ "BasicTestRunner", "run_unittest", "run_doctest", "requires_gzip", "requires_bz2", "requires_lzma", "bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute", - "requires_IEEE_754", "requires_zlib", + "requires_IEEE_754", "has_fork_support", "requires_fork", "has_subprocess_support", "requires_subprocess", "anticipate_failure", "load_package_tests", "detect_api_mismatch", @@ -453,13 +453,6 @@ def dec(*args, **kwargs): float.__getformat__("double").startswith("IEEE"), "test requires IEEE 754 doubles") -def requires_zlib(reason='requires zlib'): - try: - import zlib - except ImportError: - zlib = None - return unittest.skipUnless(zlib, reason) - def requires_gzip(reason='requires gzip'): try: import gzip diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 70033863452805..89937cf31d58ce 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1325,7 +1325,6 @@ class TestArchives(BaseTest, unittest.TestCase): ### shutil.make_archive - @support.requires_zlib() def test_make_tarball(self): # creating something to tar root_dir, base_dir = self._create_files('') @@ -1381,7 +1380,6 @@ def _create_files(self, base_dir='dist'): write_file((root_dir, 'outer'), 'xxx') return root_dir, base_dir - @support.requires_zlib() @unittest.skipUnless(shutil.which('tar'), 'Need the tar command to run') def test_tarfile_vs_tar(self): @@ -1414,7 +1412,6 @@ def test_tarfile_vs_tar(self): self.assertEqual(tarball, base_name + '.tar') self.assertTrue(os.path.isfile(tarball)) - @support.requires_zlib() def test_make_zipfile(self): # creating something to zip root_dir, base_dir = self._create_files() @@ -1451,7 +1448,6 @@ def test_make_zipfile(self): ['dist/', 'dist/sub/', 'dist/sub2/', 'dist/file1', 'dist/file2', 'dist/sub/file3']) - @support.requires_zlib() @unittest.skipUnless(shutil.which('zip'), 'Need the zip command to run') def test_zipfile_vs_zip(self): @@ -1477,7 +1473,6 @@ def test_zipfile_vs_zip(self): names2 = zf.namelist() self.assertEqual(sorted(names), sorted(names2)) - @support.requires_zlib() @unittest.skipUnless(shutil.which('unzip'), 'Need the unzip command to run') def test_unzip_zipfile(self): @@ -1506,7 +1501,6 @@ def test_make_archive(self): base_name = os.path.join(tmpdir, 'archive') self.assertRaises(ValueError, make_archive, base_name, 'xxx') - @support.requires_zlib() def test_make_archive_owner_group(self): # testing make_archive with owner and group, with various combinations # this works even if there's not gid/uid support @@ -1533,8 +1527,6 @@ def test_make_archive_owner_group(self): owner='kjhkjhkjg', group='oihohoh') self.assertTrue(os.path.isfile(res)) - - @support.requires_zlib() @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support") def test_tarfile_root_owner(self): root_dir, base_dir = self._create_files() @@ -1579,7 +1571,6 @@ def test_make_tarfile_in_curdir(self): self.assertEqual(make_archive('test', 'tar'), 'test.tar') self.assertTrue(os.path.isfile('test.tar')) - @support.requires_zlib() def test_make_zipfile_in_curdir(self): # Issue #21280 root_dir = self.mkdtemp() @@ -1634,7 +1625,6 @@ def check_unpack_archive_with_converter(self, format, converter): def test_unpack_archive_tar(self): self.check_unpack_archive('tar') - @support.requires_zlib() def test_unpack_archive_gztar(self): self.check_unpack_archive('gztar') @@ -1647,7 +1637,6 @@ def test_unpack_archive_bztar(self): def test_unpack_archive_xztar(self): self.check_unpack_archive('xztar') - @support.requires_zlib() def test_unpack_archive_zip(self): self.check_unpack_archive('zip')