From d075b2736028ebee249a890bea345c00020ee78a Mon Sep 17 00:00:00 2001 From: Manfred Riem <15701806+mnriem@users.noreply.github.com> Date: Thu, 9 Jul 2026 12:21:50 -0500 Subject: [PATCH] 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> --- tests/test_command_template_py_scripts.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_command_template_py_scripts.py b/tests/test_command_template_py_scripts.py index 6ad687964..aed690688 100644 --- a/tests/test_command_template_py_scripts.py +++ b/tests/test_command_template_py_scripts.py @@ -39,6 +39,17 @@ def _pin_interpreter(monkeypatch): "specify_cli.integrations.base.shutil.which", lambda name: "/usr/bin/python3" if name == "python3" else None, ) + # 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 would fail and the resolver would fall back to ``sys.executable`` + # (a ``...python.exe`` path), breaking the ``python3``-anchored assertion. + # Pin the probe to True so the interpreter token stays ``python3`` on all + # platforms. + monkeypatch.setattr( + "specify_cli.integrations.base.IntegrationBase._interpreter_runs", + staticmethod(lambda path: True), + ) def test_py_templates_discovered():