Skip to content

Commit

Permalink
pythongh-112795: Move the test for ZipFile into the core tests for zi…
Browse files Browse the repository at this point in the history
…pfile. (python#116823)

Move the test for ZipFile into the core tests for zipfile.
  • Loading branch information
jaraco authored and diegorusso committed Apr 17, 2024
1 parent 56009a3 commit e36577b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
12 changes: 0 additions & 12 deletions Lib/test/test_zipfile/_path/test_path.py
Expand Up @@ -577,15 +577,3 @@ def test_getinfo_missing(self, alpharep):
zipfile.Path(alpharep)
with self.assertRaises(KeyError):
alpharep.getinfo('does-not-exist')

def test_root_folder_in_zipfile(self):
"""
gh-112795: Some tools or self constructed codes will add '/' folder to
the zip file, this is a strange behavior, but we should support it.
"""
in_memory_file = io.BytesIO()
zf = zipfile.ZipFile(in_memory_file, "w")
zf.mkdir('/')
zf.writestr('./a.txt', 'aaa')
tmpdir = pathlib.Path(self.fixtures.enter_context(temp_dir()))
zf.extractall(tmpdir)
11 changes: 11 additions & 0 deletions Lib/test/test_zipfile/test_core.py
Expand Up @@ -3033,6 +3033,17 @@ def test_create_directory_with_write(self):

self.assertEqual(set(os.listdir(target)), {"directory", "directory2"})

def test_root_folder_in_zipfile(self):
"""
gh-112795: Some tools or self constructed codes will add '/' folder to
the zip file, this is a strange behavior, but we should support it.
"""
in_memory_file = io.BytesIO()
zf = zipfile.ZipFile(in_memory_file, "w")
zf.mkdir('/')
zf.writestr('./a.txt', 'aaa')
zf.extractall(TESTFN2)

def tearDown(self):
rmtree(TESTFN2)
if os.path.exists(TESTFN):
Expand Down

0 comments on commit e36577b

Please sign in to comment.