Skip to content

Remove unneeded zlib dependency in zipfile tests #135631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Lib/test/test_zipfile/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1894,8 +1894,7 @@ def create_zipfile_with_extra_data(self, filename, extra_data_name):
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')
Expand All @@ -1905,19 +1904,16 @@ def create_zipfile_with_extra_data(self, filename, extra_data_name):
# 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):
Expand Down
Loading