]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-112795: Move the test for ZipFile into the core tests for zipfile. (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 14 Mar 2024 20:24:19 +0000 (21:24 +0100)
committerGitHub <noreply@github.com>
Thu, 14 Mar 2024 20:24:19 +0000 (16:24 -0400)
gh-112795: Move the test for ZipFile into the core tests for zipfile. (GH-116823)

Move the test for ZipFile into the core tests for zipfile.
(cherry picked from commit fd8e30eb62d0ecfb75786df1ac25593b0143cc98)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Lib/test/test_zipfile/_path/test_path.py
Lib/test/test_zipfile/test_core.py

index 171ab6fdb5fc28e65a995c25bdc0db830f9c4f3c..c66cb3cba69ebd05de2fb0a51b796d3e7f1a05c9 100644 (file)
@@ -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)
index b63eb0c9339864c3c3392ff771237a10b0c5fc3a..ae58145d3c72c8b8469275bf71161b00029e6bba 100644 (file)
@@ -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):