Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
- :gh:`81` adds a warning if a path is not correctly cased on a case-insensitive file
system. This facilitates cross-platform builds of projects. Deactivate the check by
setting ``check_casing_of_paths = false`` in the configuration file.
- :gh:`84` fixes an error in the path normalization introduced by :gh:`81`.


0.0.14 - 2021-03-23
Expand Down
8 changes: 5 additions & 3 deletions src/_pytask/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ def pytask_collect_node(session, path, node):
node = Path(node)
if isinstance(node, Path):
if not node.is_absolute():
# ``normpath`` removes ``../`` from the path which is necessary for the
# casing check which will fail since ``.resolves()`` also normalizes a path.
node = Path(os.path.normpath(path.parent.joinpath(node)))
node = path.parent.joinpath(node)

# ``normpath`` removes ``../`` from the path which is necessary for the casing
# check which will fail since ``.resolves()`` also normalizes a path.
node = Path(os.path.normpath(node))

if (
not IS_FILE_SYSTEM_CASE_SENSITIVE
Expand Down
8 changes: 7 additions & 1 deletion tests/test_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,17 @@ def test_pytask_collect_node_raises_error_if_path_is_not_correctly_cased(tmp_pat


@pytest.mark.unit
def test_pytask_collect_node_does_not_raise_error_if_path_is_not_normalized(tmp_path):
@pytest.mark.parametrize("is_absolute", [True, False])
def test_pytask_collect_node_does_not_raise_error_if_path_is_not_normalized(
tmp_path, is_absolute
):
session = Session({"check_casing_of_paths": True}, None)
task_path = tmp_path / "task_example.py"
real_node = tmp_path / "text.txt"

collected_node = f"../{tmp_path.name}/text.txt"
if is_absolute:
collected_node = tmp_path / collected_node

with pytest.warns(None) as record:
result = pytask_collect_node(session, task_path, collected_node)
Expand Down