mirror of https://github.com/python/cpython
gh-112795: Move the test for ZipFile into the core tests for zipfile. (#116823)
Move the test for ZipFile into the core tests for zipfile.
This commit is contained in:
parent
61e54bfcee
commit
fd8e30eb62
|
@ -577,15 +577,3 @@ class TestPath(unittest.TestCase):
|
|||
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)
|
||||
|
|
|
@ -3033,6 +3033,17 @@ class TestWithDirectory(unittest.TestCase):
|
|||
|
||||
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):
|
||||
|
|
Loading…
Reference in New Issue