Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def absolute_file_path(tmp_path: pathlib.Path) -> pathlib.Path:

@pytest.fixture
def relative_file_path(absolute_file_path: pathlib.Path) -> pathlib.Path:
cwd = pathlib.Path.cwd()
if os.name == 'nt' and absolute_file_path.anchor != cwd.anchor:
# on windows, cant create relative path when paths are on different drives
return absolute_file_path
return pathlib.Path(os.path.relpath(absolute_file_path, os.getcwd()))


Expand All @@ -56,6 +60,10 @@ def absolute_directory_path(tmp_path: pathlib.Path) -> pathlib.Path:

@pytest.fixture
def relative_directory_path(absolute_directory_path: pathlib.Path) -> pathlib.Path:
cwd = pathlib.Path.cwd()
if os.name == 'nt' and absolute_directory_path.anchor != cwd.anchor:
# on windows, cant create relative path when paths are on different drives
return absolute_directory_path
return pathlib.Path(os.path.relpath(absolute_directory_path, os.getcwd()))


Expand All @@ -66,6 +74,10 @@ def absolute_new_path(tmp_path: pathlib.Path) -> pathlib.Path:

@pytest.fixture
def relative_new_path(absolute_new_path: pathlib.Path) -> pathlib.Path:
cwd = pathlib.Path.cwd()
if os.name == 'nt' and absolute_new_path.anchor != cwd.anchor:
# on windows, cant create relative path when paths are on different drives
return absolute_new_path
return pathlib.Path(os.path.relpath(absolute_new_path, os.getcwd()))


Expand Down