fix: clean up CF_ORCH_URL/GPU_SERVER_URL env leak in test_config.py
Found during freeze-branch integration testing (PR #12 + #14 + #15 combined): app/config.py's write-back (os.environ["CF_ORCH_URL"] = GPU_SERVER_URL) is a module-level side effect monkeypatch never tracks, so it wasn't being reverted between tests. Once any test_config.py test set a truthy GPU_SERVER_URL/CF_LICENSE_KEY, the resulting CF_ORCH_URL wrote leaked into every later test in the same pytest session. This silently broke all five "skips_embeddings_without_ollama_url" tests across the shelve_*.py suite (pdf, docx, odt, ods, xlsx) — their get_llm_config() check no longer saw a clean "nothing configured" state, so they attempted embedding instead of skipping it. Neither PR #12 nor #14 alone exercised this combination in the same test session, so it only surfaced once merged together. Fix: explicitly pop CF_ORCH_URL/GPU_SERVER_URL/CF_LICENSE_KEY from os.environ in the autouse teardown fixture before reloading app.config, rather than relying on monkeypatch to catch a write it never made itself.
This commit is contained in:
parent
76aaabd857
commit
10cde880b6
1 changed files with 8 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ environment restored so later tests see normal module state.
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
@ -18,6 +19,13 @@ import app.config as config
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def _restore_config_module():
|
def _restore_config_module():
|
||||||
yield
|
yield
|
||||||
|
# config.py's write-back (`os.environ["CF_ORCH_URL"] = GPU_SERVER_URL`) is a
|
||||||
|
# module-level side effect monkeypatch never sees, so it can't auto-revert
|
||||||
|
# it — without this explicit cleanup, a value set here leaks into every
|
||||||
|
# other test in the session (e.g. shelve tests' get_llm_config() checks).
|
||||||
|
os.environ.pop("CF_ORCH_URL", None)
|
||||||
|
os.environ.pop("GPU_SERVER_URL", None)
|
||||||
|
os.environ.pop("CF_LICENSE_KEY", None)
|
||||||
importlib.reload(config)
|
importlib.reload(config)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue