Skip to content

Commit

Permalink
add tests for Path.parts
Browse files Browse the repository at this point in the history
  • Loading branch information
jonburdo authored and efiop committed Jan 7, 2022
1 parent 05b5e9d commit 634246f
Showing 1 changed file with 29 additions and 0 deletions.
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

0 comments on commit 634246f

Please sign in to comment.