diff --git a/tests/unit/fs/test_path.py b/tests/unit/fs/test_path.py new file mode 100644 index 0000000000..caf41342c6 --- /dev/null +++ b/tests/unit/fs/test_path.py @@ -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