File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 66
77
88def 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 )
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments