]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151866: Remove unneeded `zlib` dependency in `test_zipfile.test_core` (#135631)
authorDanny Lin <danny0838@gmail.com>
Mon, 22 Jun 2026 14:11:24 +0000 (22:11 +0800)
committerGitHub <noreply@github.com>
Mon, 22 Jun 2026 14:11:24 +0000 (15:11 +0100)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Lib/test/test_zipfile/test_core.py

index c0f3efaf0921da83798a2c66c367c82ded9e5c7f..4f20209927e7b3df8c32fb5285140f72876c96d2 100644 (file)
@@ -4089,8 +4089,7 @@ class OtherTests(unittest.TestCase):
             tag_for_unicode_path = b'\x75\x70'
             version_of_unicode_path = b'\x01'
 
-            import zlib
-            filename_crc = struct.pack('<L', zlib.crc32(filename_encoded))
+            filename_crc = struct.pack('<L', zipfile.crc32(filename_encoded))
 
             extra_data = version_of_unicode_path + filename_crc + extra_data_name
             tsize = len(extra_data).to_bytes(2, 'little')
@@ -4100,19 +4099,16 @@ class OtherTests(unittest.TestCase):
             # add the file to the ZIP archive
             zf.writestr(zip_info, b'Hello World!')
 
-    @requires_zlib()
     def test_read_zipfile_containing_unicode_path_extra_field(self):
         self.create_zipfile_with_extra_data("이름.txt", "이름.txt".encode("utf-8"))
         with zipfile.ZipFile(TESTFN, "r") as zf:
             self.assertEqual(zf.filelist[0].filename, "이름.txt")
 
-    @requires_zlib()
     def test_read_zipfile_warning(self):
         self.create_zipfile_with_extra_data("이름.txt", b"")
         with self.assertWarns(UserWarning):
             zipfile.ZipFile(TESTFN, "r").close()
 
-    @requires_zlib()
     def test_read_zipfile_error(self):
         self.create_zipfile_with_extra_data("이름.txt", b"\xff")
         with self.assertRaises(zipfile.BadZipfile):