Skip to content

Commit de92aed

Browse files
committed
test_envprovider: skip symlink assertion on Windows for venv-rooted python
The Windows link_binary guard intentionally returns the venv-rooted source python.exe unchanged (since shimming it breaks CPython's pyvenv.cfg discovery). The existing linked_binary.is_symlink() / linked_binary.resolve() == sys.executable assertions therefore don't apply on Windows — there is no managed shim to inspect. Gate them behind not IS_WINDOWS and on Windows check instead that loaded.loaded_abspath == sys.executable directly.
1 parent 9b47cbd commit de92aed

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tests/test_envprovider.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from abxpkg import Binary, EnvProvider, PipProvider, SemVer
88
from abxpkg.config import load_derived_cache
99
from abxpkg.exceptions import BinaryUninstallError
10+
from abxpkg.windows_compat import IS_WINDOWS
1011

1112

1213
class TestEnvProvider:
@@ -136,9 +137,18 @@ def test_provider_with_install_root_links_loaded_binary_and_writes_derived_env(
136137
assert provider.bin_dir is not None
137138
assert provider.bin_dir.exists()
138139
assert loaded.loaded_respath == Path(sys.executable).resolve()
139-
linked_binary = provider.bin_dir / "python3"
140-
assert linked_binary.is_symlink()
141-
assert linked_binary.resolve() == Path(sys.executable).resolve()
140+
# Unix: ``_link_loaded_binary`` creates a managed symlink in
141+
# ``bin_dir`` pointing to ``sys.executable``. Windows: venv-
142+
# rooted ``python.exe`` is returned unchanged by
143+
# ``link_binary`` because CPython's ``pyvenv.cfg`` discovery
144+
# can't follow the linked path — no shim is written, and
145+
# ``loaded_abspath`` is the real venv python.
146+
if not IS_WINDOWS:
147+
linked_binary = provider.bin_dir / "python3"
148+
assert linked_binary.is_symlink()
149+
assert linked_binary.resolve() == Path(sys.executable).resolve()
150+
else:
151+
assert loaded.loaded_abspath == Path(sys.executable)
142152

143153
derived_env_path = install_root / "derived.env"
144154
cache = load_derived_cache(derived_env_path)

0 commit comments

Comments
 (0)