Self-hosted AI workspace.
Python
Stub llm_core via monkeypatch.setitem so the cross-tenant test does not leak its fake into later test modules
afonsopc302b789b5108
diff --git a/tests/test_memory_extractor_vector_cross_tenant.py b/tests/test_memory_extractor_vector_cross_tenant.pyindex 6b1d24385..49702c17f 100644--- a/tests/test_memory_extractor_vector_cross_tenant.py+++ b/tests/test_memory_extractor_vector_cross_tenant.py@@ -32,16 +32,20 @@ def _load_extractor():return mod-def _install_llm_stub(facts_json):+def _install_llm_stub(monkeypatch, facts_json):mod = types.ModuleType("src.llm_core")async def llm_call_async(*a, **k):return facts_jsonmod.llm_call_async = llm_call_async+ # Use monkeypatch.setitem so sys.modules is restored at teardown. A raw+ # assignment here permanently replaced the real src.llm_core with this+ # stripped stub, leaking "My home is in Lisbon" (and hiding _detect_provider)+ # into every later-collected test that imports the real module.src_pkg = sys.modules.get("src") or types.ModuleType("src")- sys.modules["src"] = src_pkg- sys.modules["src.llm_core"] = mod+ monkeypatch.setitem(sys.modules, "src", src_pkg)+ monkeypatch.setitem(sys.modules, "src.llm_core", mod)class FakeSession:@@ -95,7 +99,7 @@ def test_vector_match_from_other_tenant_does_not_drop_users_fact(monkeypatch):])# The vector store reports user B's new fact as a near-duplicate of a1.vec = FakeVector(match_id="a1")- _install_llm_stub('["My home is in Lisbon"]')+ _install_llm_stub(monkeypatch, '["My home is in Lisbon"]')memory_extractor = _load_extractor()