Allow relative imports with two dots at start of path. Update unit tests.

This commit is contained in:
Beth Probert 2026-03-06 14:13:00 +00:00
parent e5429d6cda
commit 4395d4001c
2 changed files with 9 additions and 10 deletions

View file

@ -95,13 +95,12 @@ def test_make_path_safe_separators():
def test_make_path_safe_relative():
"""Test that relative path components are preserved.
We only allow relative paths with one dot, and at the beginning of the path,
to avoid issues with paths like "file./file" or "file../file
"""
"""Test that relative path components are preserved."""
# We only allow relative paths with one dot, and at the beginning of the path,
# to avoid issues with paths like "file./file" or "file../file.
assert make_path_safe("./openflexure/data/") == "./openflexure/data/"
assert make_path_safe("../openflexure/data/") == "../openflexure/data/"
assert make_path_safe("../openflexure/data/") == "_/openflexure/data/"
assert make_path_safe("path/./to/file") == "path/_/to/file"
assert make_path_safe("path/../to/file") == "path/_/to/file"
assert make_path_safe(".") == "_"