deer-flow/backend/tests/_host_path_helpers.py
Shxiao daf32cd246
test(mounts): compare host paths separator-agnostically in provisioner and mount suites (#5413)
* test(mounts): compare host paths separator-agnostically in provisioner and mount suites

The provisioner deliberately preserves host filesystem style
(join_host_path keeps native separators and os.path.normpath re-spells
POSIX inputs on Windows), and the docker --mount args and review-CLI
PYTHONPATH inherit that spelling. Six assertions across
test_provisioner_pvc_volumes, test_three_way_skills_mount_e2e and
test_review_changed_public_skills compared those strings against
POSIX-style literals, so they fail on Windows hosts while passing on
Linux CI. Normalize the host-native side before comparing; the replace
is a no-op on POSIX, so CI expectations are unchanged.

* test(mounts): share the host-path normalization helper

Both review suggestions: define posix_path once in
backend/tests/_host_path_helpers.py (matching the existing _xxx_helpers
convention) instead of three spellings across suites, and wrap the last
raw hostPath assertion (test_hostpath_userdata_includes_thread_id) so
the whole provisioner class stays separator-agnostic.
2026-09-14 11:10:41 +08:00

15 lines
649 B
Python

"""Helpers for asserting on paths the codebase spells in host-native style.
The provisioner's ``join_host_path`` deliberately preserves the host
filesystem style (explicit ``PureWindowsPath`` branch), and
``os.path.normpath`` re-spells POSIX inputs with backslashes on Windows, so
hostPath volume strings, docker ``--mount`` args and ``PYTHONPATH`` entries
carry ``\\`` on a Windows host where POSIX CI sees ``/``. Tests that match
segments inside such strings normalize with :func:`posix_path` instead of
hard-coding one separator; the replace is a no-op on POSIX inputs.
"""
def posix_path(path: str) -> str:
return path.replace("\\", "/")