test: pin interpreter probe so py-template render test passes on Windows#3428
Merged
Merged
Conversation
test_template_renders_python_invocation monkeypatches shutil.which to return /usr/bin/python3, but on Windows resolve_python_interpreter guards the which() result with a real _interpreter_runs subprocess probe (github#3304). The mocked /usr/bin/python3 path does not exist on a Windows runner, so the probe fails, the resolver falls back to sys.executable (a ...python.exe path), and the python3-anchored regex assertion fails. Patch _interpreter_runs to return True in the _pin_interpreter fixture so the resolved interpreter token stays python3 across all platforms, keeping the github#3304 production guard intact while making the assertion deterministic. Assisted-by: GitHub Copilot (model: Claude Opus 4.8, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows-only failure in tests/test_command_template_py_scripts.py::test_template_renders_python_invocation by making the interpreter pinning fixture compatible with the Windows runtime-probe behavior in IntegrationBase.resolve_python_interpreter().
Changes:
- Extend the
_pin_interpreterautouse fixture to also monkeypatchIntegrationBase._interpreter_runs()to always returnTrue. - Ensure
resolve_python_interpreter()consistently resolves to thepython3token under test across platforms (instead of falling back tosys.executableon Windows).
Show a summary per file
| File | Description |
|---|---|
| tests/test_command_template_py_scripts.py | Pins the Windows-only _interpreter_runs probe during tests so rendered py: invocations stay anchored to python3. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Low
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
tests/test_command_template_py_scripts.py::test_template_renders_python_invocationfails on Windows runners (all 6py:-scripted command templates) while passing on Linux/macOS — see run 29023156913.Root cause
The
_pin_interpreterfixture monkeypatchesshutil.whichto return/usr/bin/python3, intending to pin the rendered interpreter token topython3. But on Windows,resolve_python_interpreter()guards thewhich()result with a real_interpreter_runs()subprocess probe (added in #3304 to skip the Microsoft Store App Execution Alias stub):The mocked
/usr/bin/python3path doesn't exist on a Windows runner, so the probe returnsFalse, bothpython3andpythonare skipped, and the resolver falls back tosys.executable(e.g.C:\hostedtoolcache\...\python.exe). The rendered invocation then starts with a Windowspython.exepath instead ofpython3, failing the assertion:Fix
Patch
_interpreter_runsto returnTruein the_pin_interpreterfixture so the resolved interpreter token stayspython3across all platforms. This keeps the #3304 production guard fully intact — only the test's mock is made platform-independent.Testing
pytest tests/test_command_template_py_scripts.py→ 20 passed locally (macOS). The fix targets the Windows-only fallback path.Opened by GitHub Copilot (model: Claude Opus 4.8) on behalf of @mnriem.