Repository navigation
Python: Resolve Windows shell tool executables from PATH only #10229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Eduard van Valkenburg (eavanvalkenburg)
merged 4 commits into
microsoft:main
from
eavanvalkenburg:shell-executable-lookup
Nov 10, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
169105c
Python: Resolve Windows shell tool executables from PATH only
eavanvalkenburg 49e32c3
Python: Remove the legacy package marker from the tools tests
eavanvalkenburg a6a3601
Python: Make the fake Windows host in the shell tool tests independen…
eavanvalkenburg 07c455c
Python: Accept UNC share roots as fully qualified PATH entries
eavanvalkenburg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| """Shared fixtures for the shell tool tests.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| import sys | ||
| from collections.abc import Callable, Iterable | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def fake_windows_host(monkeypatch: pytest.MonkeyPatch) -> Callable[[str, Iterable[str]], None]: | ||
| """Return a factory that makes the process look like a Windows host. | ||
|
|
||
| Each call sets ``sys.platform`` and ``PATH``, and makes ``os.path.isfile`` report only the given files. A | ||
| later call replaces the files of an earlier call. The host file system is never consulted, so a real | ||
| installation directory cannot change the result. No file is created and no executable is started, so tests | ||
| that use it behave the same on every platform. | ||
| """ | ||
|
|
||
| def configure(path_env: str, files: Iterable[str]) -> None: | ||
| known = frozenset(files) | ||
|
|
||
| def isfile(candidate: str | os.PathLike[str]) -> bool: | ||
| return os.fspath(candidate) in known | ||
|
|
||
| monkeypatch.setattr(sys, "platform", "win32") | ||
| monkeypatch.setenv("PATH", path_env) | ||
| monkeypatch.setattr(os.path, "isfile", isfile) | ||
|
|
||
| return configure |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.