diff --git a/tests/conftest.py b/tests/conftest.py index 433ca9a..18be2f3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,6 +3,26 @@ import pytest + +@pytest.fixture(autouse=True) +def _no_ambient_operator_tokens(monkeypatch): + """Never let a developer's real envs.json reach a test process. + + `adclaw/__init__.py` calls `load_envs_into_environ()` at import time, so + whatever is saved in Settings > Environments on this machine becomes + ambient environment for every test in the suite — not just the ones + that opted in. Most campaign tests deliberately exercise the + *unauthenticated* path (MASKANX_OPERATOR_TOKENS unset), so once a real + operator token is configured for actual use, require_operator starts + demanding a header those tests never send, and they fail with 401 + instead of the status the test is actually about. 28 tests broke this + way the first time a real token was set. + + A test that wants a token still gets one: its own monkeypatch.setenv + runs after this fixture in the same test and overrides it. + """ + monkeypatch.delenv("MASKANX_OPERATOR_TOKENS", raising=False) + from adclaw.memory_agent.embeddings import FakeEmbeddingPipeline from adclaw.memory_agent.models import AOMConfig from adclaw.memory_agent.store import MemoryStore