Skip to content

Commit d075b27

Browse files
mnriemCopilot
andauthored
test: pin interpreter probe so py-template render test passes on Windows (#3428)
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 (#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 #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>
1 parent eedf73f commit d075b27

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/test_command_template_py_scripts.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ def _pin_interpreter(monkeypatch):
3939
"specify_cli.integrations.base.shutil.which",
4040
lambda name: "/usr/bin/python3" if name == "python3" else None,
4141
)
42+
# On Windows, ``resolve_python_interpreter`` guards the ``which`` result
43+
# with a real ``_interpreter_runs`` subprocess probe (#3304). The mocked
44+
# ``/usr/bin/python3`` path does not exist on a Windows runner, so the
45+
# probe would fail and the resolver would fall back to ``sys.executable``
46+
# (a ``...python.exe`` path), breaking the ``python3``-anchored assertion.
47+
# Pin the probe to True so the interpreter token stays ``python3`` on all
48+
# platforms.
49+
monkeypatch.setattr(
50+
"specify_cli.integrations.base.IntegrationBase._interpreter_runs",
51+
staticmethod(lambda path: True),
52+
)
4253

4354

4455
def test_py_templates_discovered():

0 commit comments

Comments
 (0)