Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion upath/_flavour.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def splitext(self, path: PathOrStr) -> tuple[str, str]:
return os.path.splitext(path)
else:
path, sep, name = path.rpartition(self.sep)
if name:
if "." in name:
stem, dot, ext = name.rpartition(".")
suffix = dot + ext
else:
Expand Down
16 changes: 16 additions & 0 deletions upath/tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,22 @@ def test_with_suffix(self):
path = path.with_suffix(".zip")
assert path.suffix == ".zip"

def test_suffix(self):
path = self.path / "no_suffix"
assert path.suffix == ""
path = self.path / "file.txt"
assert path.suffix == ".txt"
path = self.path / "archive.tar.gz"
assert path.suffix == ".gz"

def test_suffixes(self):
path = self.path / "no_suffix"
assert path.suffixes == []
path = self.path / "file.txt"
assert path.suffixes == [".txt"]
path = self.path / "archive.tar.gz"
assert path.suffixes == [".tar", ".gz"]

def test_with_stem(self):
if sys.version_info < (3, 9):
pytest.skip("with_stem only available on py3.9+")
Expand Down
6 changes: 6 additions & 0 deletions upath/tests/implementations/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ def test_with_suffix(self):
with pytest.raises(NotImplementedError):
self.path.with_suffix(".new")

def test_suffix(self):
assert self.path.suffix == ""

def test_suffixes(self):
assert self.path.suffixes == []

def test_with_stem(self):
with pytest.raises(NotImplementedError):
self.path.with_stem("newname")
Expand Down
Loading