test(mem0): setup module keeps post_setup when discovery imports the package first

The plugin loader execs sibling modules before the package __init__, so a
module-level `from . import _read_mem0_json` in _setup.py failed against the
empty parent shell and the whole module silently dropped out — every later
`hermes memory setup mem0` died with "cannot import name 'post_setup'".
The test loads mem0 through the real discovery path from a cold sys.modules
and asserts the cached _setup module exposes post_setup (red on base).

Also maps the contributor email for #103078 credit.

Campaign tracker: https://github.com/NousResearch/hermes-agent/issues/104154
This commit is contained in:
Teknium
2026-09-06 02:21:43 -07:00
parent e8521f47f9
commit c8cbc07030
2 changed files with 20 additions and 0 deletions
+18
View File
@@ -253,3 +253,21 @@ class TestConnectivityChecks:
assert ok is True
def test_discovery_loaded_setup_module_exposes_post_setup(monkeypatch):
"""`hermes memory setup mem0` reaches the wizard when the package is first imported by plugin
discovery, which execs sibling modules before ``__init__`` (#103078). The invariant is on the
module the loader actually cached, not on a normal top-level import."""
from plugins.memory import load_memory_provider
saved = {k: sys.modules.pop(k) for k in list(sys.modules) if k.startswith("plugins.memory.mem0")}
try:
provider = load_memory_provider("mem0", register_skills=False)
assert provider is not None
assert hasattr(sys.modules["plugins.memory.mem0._setup"], "post_setup")
finally:
for k in list(sys.modules):
if k.startswith("plugins.memory.mem0"):
del sys.modules[k]
sys.modules.update(saved)