diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-03-14 20:24:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-14 20:24:19 (GMT) |
commit | 988246a17b69e7c3077c7456bc50d04d6f153c5d (patch) | |
tree | eac30dd457dad7e26d64901e6659387e6c3bff77 /Lib | |
parent | 9d08e14a0038a03f042f2540d3680530059aa1fd (diff) | |
download | cpython-988246a17b69e7c3077c7456bc50d04d6f153c5d.zip cpython-988246a17b69e7c3077c7456bc50d04d6f153c5d.tar.gz cpython-988246a17b69e7c3077c7456bc50d04d6f153c5d.tar.bz2 |
[3.12] gh-112795: Move the test for ZipFile into the core tests for zipfile. (GH-116823) (#116830)
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>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_zipfile/_path/test_path.py | 12 | ||||
-rw-r--r-- | Lib/test/test_zipfile/test_core.py | 11 |
2 files changed, 11 insertions, 12 deletions
diff --git a/Lib/test/test_zipfile/_path/test_path.py b/Lib/test/test_zipfile/_path/test_path.py index 171ab6f..c66cb3c 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 b63eb0c..ae58145 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): |