Merge pull request #456 from AIOSAI/system/devpulse-fix-python-310-mockpatch-add-detector-import-to-mo
feat(system): fix: Python 3.10 mock.patch — add detector import to monitor/__init__.py + fix chroma_client module split in symbolic tests
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user