@@ -19,21 +19,40 @@ def _mocked_home(tmp_path: Path) -> Iterator[Path]:
1919 yield tmp_path
2020
2121
22- def test_check_path_relative (mocked_home : Path ) -> None :
22+ def test_check_path_relative_ok (mocked_home : Path ) -> None :
23+ (mocked_home / "tmp/debug" ).mkdir (parents = True , exist_ok = True )
2324 with chdir (mocked_home ):
24- with pytest .raises (ValueError ):
25- _check_path ("foo" )
2625 _check_path ("tmp/debug/foo" )
2726
28- some_dir = mocked_home / "foobar"
29- some_dir .mkdir ()
30- with chdir (some_dir ):
31- with pytest .raises (ValueError ):
32- _check_path ("tmp/debug/foo" )
33- _check_path ("../tmp/debug/foo" )
27+
28+ def test_check_path_relative_missing (mocked_home : Path ) -> None :
29+ with chdir (mocked_home ), pytest .raises (NotADirectoryError ):
30+ _check_path ("tmp/debug/foo" )
31+
32+
33+ def test_check_path_relative_too_far_down (mocked_home : Path ) -> None :
34+ (mocked_home / "tmp/debug" ).mkdir (parents = True , exist_ok = True )
35+ with chdir (mocked_home / "tmp" ), pytest .raises (ValueError ):
36+ _check_path ("tmp/debug/foo" )
37+
38+
39+ def test_check_path_relative_too_far_up (mocked_home : Path ) -> None :
40+ (mocked_home / "tmp/debug" ).mkdir (parents = True , exist_ok = True )
41+ with chdir (mocked_home / ".." ), pytest .raises (ValueError ):
42+ _check_path ("tmp/debug/foo" )
43+
44+
45+ def test_check_path_absolute_ok (mocked_home : Path ) -> None :
46+ (mocked_home / "tmp/debug" ).mkdir (parents = True , exist_ok = True )
47+ _check_path (str (mocked_home / "tmp/debug/foo" ))
48+
49+
50+ def test_check_path_absolute_missing (mocked_home : Path ) -> None :
51+ with pytest .raises (NotADirectoryError ):
52+ _check_path (str (mocked_home / "tmp/debug/foo" ))
3453
3554
36- def test_check_path_absolute (mocked_home : Path ) -> None :
37- with pytest . raises ( ValueError ):
38- _check_path ( str ( mocked_home / "foo" ))
39- _check_path (str (mocked_home / "tmp" / "debug" / " foo" ))
55+ def test_check_path_absolute_invalid (mocked_home : Path ) -> None :
56+ ( mocked_home / "tmp/debug" ). mkdir ( parents = True , exist_ok = True )
57+ with chdir ( mocked_home / "tmp" ), pytest . raises ( ValueError ):
58+ _check_path (str (mocked_home / "tmp/degug/ foo" ))
0 commit comments