Skip to content

Commit f72a0e4

Browse files
committed
Fix error in path normalization.
1 parent 7f04fc9 commit f72a0e4

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

docs/changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
1414
- :gh:`81` adds a warning if a path is not correctly cased on a case-insensitive file
1515
system. This facilitates cross-platform builds of projects. Deactivate the check by
1616
setting ``check_casing_of_paths = false`` in the configuration file.
17+
- :gh:`84` fixes an error in the path normalization introduced by :gh:`81`.
1718

1819

1920
0.0.14 - 2021-03-23

src/_pytask/collect.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,11 @@ def pytask_collect_node(session, path, node):
183183
node = Path(node)
184184
if isinstance(node, Path):
185185
if not node.is_absolute():
186-
# ``normpath`` removes ``../`` from the path which is necessary for the
187-
# casing check which will fail since ``.resolves()`` also normalizes a path.
188-
node = Path(os.path.normpath(path.parent.joinpath(node)))
186+
node = path.parent.joinpath(node)
187+
188+
# ``normpath`` removes ``../`` from the path which is necessary for the casing
189+
# check which will fail since ``.resolves()`` also normalizes a path.
190+
node = Path(os.path.normpath(node))
189191

190192
if (
191193
not IS_FILE_SYSTEM_CASE_SENSITIVE

tests/test_collect.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,17 @@ def test_pytask_collect_node_raises_error_if_path_is_not_correctly_cased(tmp_pat
155155

156156

157157
@pytest.mark.unit
158-
def test_pytask_collect_node_does_not_raise_error_if_path_is_not_normalized(tmp_path):
158+
@pytest.mark.parametrize("is_absolute", [True, False])
159+
def test_pytask_collect_node_does_not_raise_error_if_path_is_not_normalized(
160+
tmp_path, is_absolute
161+
):
159162
session = Session({"check_casing_of_paths": True}, None)
160163
task_path = tmp_path / "task_example.py"
161164
real_node = tmp_path / "text.txt"
165+
162166
collected_node = f"../{tmp_path.name}/text.txt"
167+
if is_absolute:
168+
collected_node = tmp_path / collected_node
163169

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

0 commit comments

Comments
 (0)