From 65cd8fea195f578ccf867b27fce7a6ceac8a0260 Mon Sep 17 00:00:00 2001 From: poria-lang Date: Mon, 10 Aug 2026 20:41:08 +0300 Subject: [PATCH] fix(test): isolate Settings() from ambient settings env vars --- tests/test_runner_root_prompt.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_runner_root_prompt.py b/tests/test_runner_root_prompt.py index 3b0a07eb..17dbecfd 100644 --- a/tests/test_runner_root_prompt.py +++ b/tests/test_runner_root_prompt.py @@ -6,6 +6,7 @@ flow through to the root agent's ``build_strix_agent`` call. from __future__ import annotations +import os from typing import Any import httpx @@ -21,6 +22,30 @@ from strix.core.agents import AgentCoordinator from strix.runtime import session_manager +_SETTINGS_ENV_PREFIXES = ( + "STRIX_", + "LLM_", + "OPENAI_", + "DEDUPE_LLM_", + "LITELLM_", + "OLLAMA_", + "PERPLEXITY_", + "POSTMAN_", +) + + +@pytest.fixture(autouse=True) +def _clear_settings_env(monkeypatch: pytest.MonkeyPatch) -> None: + """Drop ambient settings env vars so Settings() builds deterministically. + + A malformed unrelated value (e.g. a non-JSON LLM_EXTRA_HEADERS) would + otherwise make Settings() raise before the fields under test are assigned. + """ + for key in list(os.environ): + if key.startswith(_SETTINGS_ENV_PREFIXES): + monkeypatch.delenv(key, raising=False) + + def _make_rate_limit_error() -> RateLimitError: request = httpx.Request("POST", "https://api.openai.com/v1/responses") response = httpx.Response(status_code=429, request=request)