fix(test): isolate Settings() from ambient settings env vars

This commit is contained in:
poria-lang 2026-08-10 20:41:08 +03:00
parent 3f850d4dc6
commit 65cd8fea19

View file

@ -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)