From 2ffee7c8fadb0017fadaee14bd16f47887a78571 Mon Sep 17 00:00:00 2001 From: Kimi Agent Date: Sat, 14 Mar 2026 19:22:21 -0400 Subject: [PATCH] fix: python3 compatibility in shell hand tests (#56) - Use sys.executable instead of hardcoded "python" in tests - Fixes test_run_python_expression and test_run_nonzero_exit - Passes allowed_prefixes for both python and python3 --- tests/test_hands_shell.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/test_hands_shell.py b/tests/test_hands_shell.py index 27e7ecd2..4cf8e90c 100644 --- a/tests/test_hands_shell.py +++ b/tests/test_hands_shell.py @@ -10,6 +10,7 @@ Covers: """ import asyncio +import sys import pytest @@ -91,8 +92,10 @@ async def test_run_python_expression(): """Running a python one-liner should succeed.""" from infrastructure.hands.shell import ShellHand - hand = ShellHand() - result = await hand.run("python -c 'print(2 + 2)'") + # Allow both 'python' and 'python3' (sys.executable basename) + allowed = ("python", "python3") + hand = ShellHand(allowed_prefixes=allowed) + result = await hand.run(f"{sys.executable} -c 'print(2 + 2)'") assert result.success is True assert "4" in result.stdout @@ -118,8 +121,10 @@ async def test_run_nonzero_exit(): """A command that exits non-zero should return success=False.""" from infrastructure.hands.shell import ShellHand - hand = ShellHand() - result = await hand.run("python -c 'import sys; sys.exit(1)'") + # Allow both 'python' and 'python3' (sys.executable basename) + allowed = ("python", "python3") + hand = ShellHand(allowed_prefixes=allowed) + result = await hand.run(f"{sys.executable} -c 'import sys; sys.exit(1)'") assert result.success is False assert result.exit_code == 1