1
0

[loop-cycle-3] fix: isolate unit tests from local .env and real Gitea API (#1206)

This commit is contained in:
2026-03-23 22:15:37 +00:00
parent 3ed2bbab02
commit b197cf409e
2 changed files with 15 additions and 3 deletions

View File

@@ -18,6 +18,10 @@ def _make_settings(**env_overrides):
"""Create a fresh Settings instance with isolated env vars."""
from config import Settings
# Prevent Pydantic from reading .env file (local .env pollutes defaults)
_orig_config = Settings.model_config.copy()
Settings.model_config["env_file"] = None
# Strip keys that might bleed in from the test environment
clean_env = {
k: v
@@ -82,7 +86,10 @@ def _make_settings(**env_overrides):
}
clean_env.update(env_overrides)
with patch.dict(os.environ, clean_env, clear=True):
return Settings()
try:
return Settings()
finally:
Settings.model_config.update(_orig_config)
# ── normalize_ollama_url ──────────────────────────────────────────────────────