diff --git a/docs/changes.rst b/docs/changes.rst index 6e83862e..7c79b26e 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -14,6 +14,7 @@ all releases are available on `PyPI `_ 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 diff --git a/src/_pytask/collect.py b/src/_pytask/collect.py index c1bbd069..07f6c4b1 100644 --- a/src/_pytask/collect.py +++ b/src/_pytask/collect.py @@ -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 diff --git a/tests/test_collect.py b/tests/test_collect.py index f1d6e468..d08db9e9 100644 --- a/tests/test_collect.py +++ b/tests/test_collect.py @@ -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)