From: Jason R. Coombs Date: Thu, 14 Mar 2024 17:50:24 +0000 (-0400) Subject: gh-112795: Move the test for ZipFile into the core tests for zipfile. (#116823) X-Git-Tag: v3.13.0a6~313 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fd8e30eb62d0ecfb75786df1ac25593b0143cc98;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Lib/test/test_zipfile/_path/test_path.py b/Lib/test/test_zipfile/_path/test_path.py index 171ab6fdb5fc..c66cb3cba69e 100644 --- a/Lib/test/test_zipfile/_path/test_path.py +++ b/Lib/test/test_zipfile/_path/test_path.py @@ -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) diff --git a/Lib/test/test_zipfile/test_core.py b/Lib/test/test_zipfile/test_core.py index 7d89f753448d..368e60a37b05 100644 --- a/Lib/test/test_zipfile/test_core.py +++ b/Lib/test/test_zipfile/test_core.py @@ -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):