From eb501c43da860319e2dd5efec1743c5bbda87e97 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Feb 2026 02:06:45 +0000 Subject: [PATCH] fix: resolve 8 test failures from missing requests stub and wrong python path - Add `requests` to conftest.py module stubs so patch("requests.post") works in reward scoring tests without the package installed - Use sys.executable instead of bare "python" in git safety tests so the subprocess finds pytest from the venv rather than system python https://claude.ai/code/session_012Ye9nyFEiw2QQfx4bZeDmn --- tests/conftest.py | 3 +++ tests/self_coding/test_git_safety.py | 3 ++- tests/self_coding/test_git_safety_errors.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index c875503f..79d45767 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -33,6 +33,9 @@ for _mod in [ # pyzbar is optional (for QR code invite detection) "pyzbar", "pyzbar.pyzbar", + # requests is optional — used by reward scoring (swarm.learner) to call + # Ollama directly; stub so patch("requests.post") works in tests. + "requests", ]: sys.modules.setdefault(_mod, MagicMock()) diff --git a/tests/self_coding/test_git_safety.py b/tests/self_coding/test_git_safety.py index c9870550..404bd167 100644 --- a/tests/self_coding/test_git_safety.py +++ b/tests/self_coding/test_git_safety.py @@ -9,6 +9,7 @@ from __future__ import annotations import asyncio import os import subprocess +import sys import tempfile from pathlib import Path @@ -160,7 +161,7 @@ def test_pass(): """) safety = GitSafety( repo_path=temp_git_repo, - test_command="python -m pytest test_pass.py -v", + test_command=f"{sys.executable} -m pytest test_pass.py -v", ) snapshot = await safety.snapshot(run_tests=True) diff --git a/tests/self_coding/test_git_safety_errors.py b/tests/self_coding/test_git_safety_errors.py index 88c513d2..e8086ee6 100644 --- a/tests/self_coding/test_git_safety_errors.py +++ b/tests/self_coding/test_git_safety_errors.py @@ -6,6 +6,7 @@ Tests timeout handling, git failures, merge conflicts, and edge cases. from __future__ import annotations import subprocess +import sys import tempfile from pathlib import Path from unittest.mock import patch @@ -124,7 +125,7 @@ class TestGitSafetyErrors: safety = GitSafety( repo_path=repo_path, - test_command="python -m pytest test_fail.py -v", + test_command=f"{sys.executable} -m pytest test_fail.py -v", ) snapshot = await safety.snapshot(run_tests=True)