From 0c9bbfbd309428d2a91415a4749bc90c49f79628 Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Sat, 21 Nov 2026 18:24:36 -0600 Subject: [PATCH] test: compare the symlinked-root path by filesystem identity The previous realpath comparison (#724) did not normalize the Windows extended-length (\\?\\) prefix: realpath keeps it on the returned path but not on the expected one. Compare os.path.samefile of the existing parent directory plus the file name, which is immune to the prefix. Refs #711 --- changelog.d/+windows-symlink-samefile.infrastructure.md | 1 + test/unit/scan/test_folder.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelog.d/+windows-symlink-samefile.infrastructure.md diff --git a/changelog.d/+windows-symlink-samefile.infrastructure.md b/changelog.d/+windows-symlink-samefile.infrastructure.md new file mode 100644 index 00000000..33d182df --- /dev/null +++ b/changelog.d/+windows-symlink-samefile.infrastructure.md @@ -0,0 +1 @@ +Compare the symlinked-root scan test path by filesystem identity so it passes on Windows. diff --git a/test/unit/scan/test_folder.py b/test/unit/scan/test_folder.py index 347229af..41b33bec 100644 --- a/test/unit/scan/test_folder.py +++ b/test/unit/scan/test_folder.py @@ -78,6 +78,8 @@ def test_make_full_path_accepts_internal_link_and_symlinked_root(tmp_path): result = LocalFolder(root_link).make_full_path('link/new-file.txt') expected = str(root_link / 'link' / 'new-file.txt') - # On Windows, symlink resolution can return an extended-length ("\\?\\") path, - # so compare the resolved real paths rather than the raw strings. - assert os.path.realpath(result) == os.path.realpath(expected) + # Windows symlink resolution can add an extended-length ("\\?\\") prefix that + # realpath does not normalize away, so compare by filesystem identity of the + # (existing) parent directory plus the file name instead of raw strings. + assert os.path.basename(result) == os.path.basename(expected) == 'new-file.txt' + assert os.path.samefile(os.path.dirname(result), os.path.dirname(expected))