Return ``True`` if the current context references a file or
directory in the zip file.
+.. data:: Path.suffix
+
+ The file extension of the final component.
+
+ .. versionadded:: 3.11
+ Added :data:`Path.suffix` property.
+
+.. data:: Path.stem
+
+ The final path component, without its suffix.
+
+ .. versionadded:: 3.11
+ Added :data:`Path.stem` property.
+
+.. data:: Path.suffixes
+
+ A list of the path’s file extensions.
+
+ .. versionadded:: 3.11
+ Added :data:`Path.suffixes` property.
+
.. method:: Path.read_text(*, **)
Read the current file as unicode text. Positional and
root = zipfile.Path(alpharep)
assert root.name == 'alpharep.zip' == root.filename.name
+ @pass_alpharep
+ def test_suffix(self, alpharep):
+ """
+ The suffix of the root should be the suffix of the zipfile.
+ The suffix of each nested file is the final component's last suffix, if any.
+ Includes the leading period, just like pathlib.Path.
+ """
+ root = zipfile.Path(alpharep)
+ assert root.suffix == '.zip' == root.filename.suffix
+
+ b = root / "b.txt"
+ assert b.suffix == ".txt"
+
+ c = root / "c" / "filename.tar.gz"
+ assert c.suffix == ".gz"
+
+ d = root / "d"
+ assert d.suffix == ""
+
+ @pass_alpharep
+ def test_suffixes(self, alpharep):
+ """
+ The suffix of the root should be the suffix of the zipfile.
+ The suffix of each nested file is the final component's last suffix, if any.
+ Includes the leading period, just like pathlib.Path.
+ """
+ root = zipfile.Path(alpharep)
+ assert root.suffixes == ['.zip'] == root.filename.suffixes
+
+ b = root / 'b.txt'
+ assert b.suffixes == ['.txt']
+
+ c = root / 'c' / 'filename.tar.gz'
+ assert c.suffixes == ['.tar', '.gz']
+
+ d = root / 'd'
+ assert d.suffixes == []
+
+ e = root / '.hgrc'
+ assert e.suffixes == []
+
+ @pass_alpharep
+ def test_stem(self, alpharep):
+ """
+ The final path component, without its suffix
+ """
+ root = zipfile.Path(alpharep)
+ assert root.stem == 'alpharep' == root.filename.stem
+
+ b = root / "b.txt"
+ assert b.stem == "b"
+
+ c = root / "c" / "filename.tar.gz"
+ assert c.stem == "filename.tar"
+
+ d = root / "d"
+ assert d.stem == "d"
+
@pass_alpharep
def test_root_parent(self, alpharep):
root = zipfile.Path(alpharep)