Skip to content

Commit bccefd4

Browse files
committed
Add args tests.
1 parent 675652a commit bccefd4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

fsutil/args.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77

88
def get_path(path: PathIn) -> str:
9+
if path is None:
10+
return None
911
if isinstance(path, str):
1012
return os.path.normpath(path)
1113
return str(path)

tests/test_args.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
from pathlib import Path
3+
4+
import pytest
5+
6+
from fsutil.args import get_path
7+
8+
9+
@pytest.mark.parametrize(
10+
"input_path, expected",
11+
[
12+
(None, None),
13+
("", "."),
14+
("/home/user/docs", os.path.normpath("/home/user/docs")),
15+
("C:\\Users\\test", os.path.normpath("C:\\Users\\test")),
16+
("./relative/path", os.path.normpath("./relative/path")),
17+
("..", os.path.normpath("..")),
18+
(Path("/home/user/docs"), os.path.normpath("/home/user/docs")),
19+
(Path("C:\\Users\\test"), os.path.normpath("C:\\Users\\test")),
20+
(Path("./relative/path"), os.path.normpath("./relative/path")),
21+
(Path(".."), os.path.normpath("..")),
22+
],
23+
)
24+
def test_get_path(input_path, expected):
25+
assert get_path(input_path) == expected
26+
27+
28+
if __name__ == "__main__":
29+
pytest.main()

0 commit comments

Comments
 (0)