File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,11 +47,13 @@ def to_absolute_path(
4747 Returns:
4848 The input path that is an absolute path and a :py:class:`pathlib.Path` object.
4949 """
50- # care for windows, see issue 22
51- must_exist = os_name () == 'nt'
5250
51+ must_exist = False
5352 pathlike = Path (input_path )
5453 if parent :
54+ if not parent .is_absolute ():
55+ # care for windows, see issue 22
56+ must_exist = os_name () == 'nt'
5557 pathlike = parent .joinpath (pathlike )
5658 if must_be_in_parent :
5759 try :
@@ -60,5 +62,8 @@ def to_absolute_path(
6062 raise ValueError (
6163 f"Input path { input_path } is not a subpath of parent { parent } "
6264 ) from exc
65+ else :
66+ # care for windows, see issue 22
67+ must_exist = os_name () == 'nt'
6368
6469 return pathlike .expanduser ().resolve (strict = must_exist )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ def test_to_absolute_path():
1414 expected = Path .home () / "nonexistent_file.txt"
1515 assert parsed == expected
1616
17+
1718@patch ("PyStemmusScope.utils.os_name" )
1819def test_to_absolute_path_must_exist (mocked_osname ):
1920 input_path = "~/nonexistent_file.txt"
You can’t perform that action at this time.
0 commit comments