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 dvc/fs/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def join(self, *parts):
return self.flavour.join(*parts)

def parts(self, path):
drive, path = self.flavour.splitdrive(path)
drive, path = self.flavour.splitdrive(path.rstrip(self.flavour.sep))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a simple unit test for this? (e.g. create tests/unit/fs/test_path.py for it) This module is kinda experimental, but since we are fixing such things already, it would be great to keep track of them.


ret = []
while True:
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/fs/test_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest

from dvc.fs.path import Path


@pytest.mark.parametrize("prefix", ["", "/"])
@pytest.mark.parametrize("postfix", ["", "/"])
@pytest.mark.parametrize(
"path,expected",
[
("path", ("path",)),
("some/path", ("some", "path")),
],
)
def test_parts_posix(prefix, postfix, path, expected):
assert Path("/").parts(prefix + path + postfix) == tuple(prefix) + expected


@pytest.mark.parametrize("postfix", ["", "\\"])
@pytest.mark.parametrize(
"path,expected",
[
("path", ("path",)),
("c:\\path", ("c:", "\\", "path")),
("some\\path", ("some", "path")),
],
)
def test_parts_nt(postfix, path, expected):
assert Path("\\").parts(path + postfix) == expected