From a4e1244e56cf93bc93e2db3f1a23eab54ac5155b Mon Sep 17 00:00:00 2001 From: AIOSAI Date: Sun, 26 Apr 2026 01:08:45 -0700 Subject: [PATCH] =?UTF-8?q?feat(system):=20fix:=20Python=203.10=20mock.pat?= =?UTF-8?q?ch=20=E2=80=94=20add=20detector=20import=20to=20monitor/=5F=5Fi?= =?UTF-8?q?nit=5F=5F.py=20+=20fix=20chroma=5Fclient=20module=20split=20in?= =?UTF-8?q?=20symbolic=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: @devpulse --- src/aipass/memory/apps/handlers/monitor/__init__.py | 4 ++++ src/aipass/memory/tests/test_symbolic_extras.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/aipass/memory/apps/handlers/monitor/__init__.py b/src/aipass/memory/apps/handlers/monitor/__init__.py index 2143f07d..91872456 100644 --- a/src/aipass/memory/apps/handlers/monitor/__init__.py +++ b/src/aipass/memory/apps/handlers/monitor/__init__.py @@ -1,2 +1,6 @@ # Minimal __init__.py - handler independence pattern # No exports - handlers import directly when needed + +# Python 3.10 mock.patch compatibility — submodules must be importable as +# attributes for mock._dot_lookup to resolve dotted paths. +from . import detector # noqa: F401 diff --git a/src/aipass/memory/tests/test_symbolic_extras.py b/src/aipass/memory/tests/test_symbolic_extras.py index 789d944c..1c6846e6 100644 --- a/src/aipass/memory/tests/test_symbolic_extras.py +++ b/src/aipass/memory/tests/test_symbolic_extras.py @@ -1177,6 +1177,13 @@ class TestDeleteFragment: s = _import_storage() client = _mock_chroma_client() + # Re-import chroma_client so mock.patch and the code resolve to the + # same module object. The autouse fixture deletes it from sys.modules; + # on Python 3.10 mock._dot_lookup finds a stale parent attribute. + import importlib + + importlib.import_module("aipass.memory.apps.handlers.symbolic.chroma_client") + with patch( "aipass.memory.apps.handlers.symbolic.chroma_client.get_client", return_value=client, @@ -1193,6 +1200,10 @@ class TestDeleteFragment: client = _mock_chroma_client() client.get_or_create_collection.side_effect = RuntimeError("db locked") + import importlib + + importlib.import_module("aipass.memory.apps.handlers.symbolic.chroma_client") + with patch( "aipass.memory.apps.handlers.symbolic.chroma_client.get_client", return_value=client,