From 23fb5e169a0407d7e146901160966af1bf05e6a0 Mon Sep 17 00:00:00 2001 From: Alexandre Teixeira <111787685+alteixeira20@users.noreply.github.com> Date: Thu, 4 Jun 2026 23:35:34 +0100 Subject: [PATCH] fix(tests): make cookbook venv fallback test deterministic Makes the cookbook venv fallback-chain test deterministic by simulating the inside-venv shell state directly instead of depending on the GitHub runner Python environment. Final focused #2580 CI-baseline cleanup. --- tests/test_cookbook_helpers.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_cookbook_helpers.py b/tests/test_cookbook_helpers.py index de50dda..0b6a045 100644 --- a/tests/test_cookbook_helpers.py +++ b/tests/test_cookbook_helpers.py @@ -125,15 +125,15 @@ def test_pip_install_fallback_chain_propagates_failure_in_venv(): reported success even though nothing was installed. The negated `{ ! venv_check && user }` shape propagates the failure correctly. """ - import shlex - py = shlex.quote(sys.executable) - # Use the venv python so venv_check detects we're in a venv. + # Simulate "inside a venv" deterministically: the venv check exits 0. # Base install fails, venv_check exits 0, negated to 1, - # && skips user, group exits 1. + # && skips user, group exits 1. This avoids depending on whether the + # test runner's own interpreter happens to be inside a venv (which + # differs between local and CI environments). script = ( - f"{py} -c 'import sys; sys.exit(1)' || " - f"{{ ! {py} -c \"import sys; sys.exit(0 if sys.prefix != sys.base_prefix else 1)\" " - f"&& echo user_attempt; }}" + "false || " + "{ ! true " # venv_check=0 (in venv) → negated to 1 → user skipped + "&& echo user_attempt; }" ) result = subprocess.run( ["bash", "-c", script],