[3.14] gh-135276: Refresh zipfile.Path from zipp 3.23 (GH-135277) (#135278)

* gh-135276: Refresh `zipfile.Path` from zipp 3.23 (GH-135277)

Apply changes from zipp 3.23
(cherry picked from commit 8d6eb0c262)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

* Removed features slated for Python 3.15 only.

---------

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
This commit is contained in:
Miss Islington (bot) 2025-06-08 22:12:25 +02:00 committed by GitHub
parent cf2209f5b9
commit 00f824dc5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 29 additions and 19 deletions

View file

@ -1,6 +1,6 @@
import contextlib
import io
import itertools
import contextlib
import pathlib
import pickle
import stat
@ -9,12 +9,11 @@
import zipfile
import zipfile._path
from test.support.os_helper import temp_dir, FakePath
from test.support.os_helper import FakePath, temp_dir
from ._functools import compose
from ._itertools import Counter
from ._test_params import parameterize, Invoked
from ._test_params import Invoked, parameterize
class jaraco:
@ -193,10 +192,10 @@ def test_encoding_warnings(self, alpharep):
"""EncodingWarning must blame the read_text and open calls."""
assert sys.flags.warn_default_encoding
root = zipfile.Path(alpharep)
with self.assertWarns(EncodingWarning) as wc:
with self.assertWarns(EncodingWarning) as wc: # noqa: F821 (astral-sh/ruff#13296)
root.joinpath("a.txt").read_text()
assert __file__ == wc.filename
with self.assertWarns(EncodingWarning) as wc:
with self.assertWarns(EncodingWarning) as wc: # noqa: F821 (astral-sh/ruff#13296)
root.joinpath("a.txt").open("r").close()
assert __file__ == wc.filename
@ -364,6 +363,17 @@ def test_root_name(self, alpharep):
root = zipfile.Path(alpharep)
assert root.name == 'alpharep.zip' == root.filename.name
@pass_alpharep
def test_root_on_disk(self, alpharep):
"""
The name/stem of the root should match the zipfile on disk.
This condition must hold across platforms.
"""
root = zipfile.Path(self.zipfile_ondisk(alpharep))
assert root.name == 'alpharep.zip' == root.filename.name
assert root.stem == 'alpharep' == root.filename.stem
@pass_alpharep
def test_suffix(self, alpharep):
"""