Skip to content

Windows: test_error_message_names_rejected_path fails on main due to repr backslash escapes #1702

@brendancol

Description

@brendancol

Describe the bug

xrspatial/geotiff/tests/test_vrt_path_containment_1671.py::test_error_message_names_rejected_path fails on windows-latest, 3.12 (and presumably the other Windows matrix entries before fail-fast cancellation). Currently red on main; first failure shown in main pytest run 25752793295.

Failure:

assert 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pytest-of-runneradmin\\pytest-0\\test_error_message_names_rejec0\\vrt_1671_msg_check_8d803fb0'
       in "VRT SourceFilename 'C:\\\\Users\\\\runneradmin\\\\AppData\\\\Local\\\\Temp\\\\pytest-of-runneradmin\\\\pytest-0\\\\et..._check_8d803fb0') and is not covered by any XRSPATIAL_VRT_ALLOWED_ROOTS entry ([]). Refusing to read; see issue #1671."

Root cause

The error message in parse_vrt (_vrt.py:304-307) uses {filename!r} and {vrt_root!r}. repr() doubles backslashes on Windows paths, so the message contains 'C:\\\\Users\\\\...'. The assertion in the test compares against os.path.realpath(vrt_dir) which returns the raw path with single backslashes.

The same doubled-escape output is also user-hostile on Windows — operators reading the error see noise instead of a clean path.

Suggested fix

Switch {filename!r} to '{filename}' (explicit single quotes, no repr) and same for vrt_root. Keep {allowed_roots!r} since it's a list and the list-repr is fine cross-platform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginput-validationInput validation and error messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions