refactor(tests): reuse CLI loader in more tests (#2571)

This commit is contained in:
Alexandre Teixeira
2026-06-05 02:42:10 +01:00
committed by GitHub
parent ae48ea7064
commit 51e668ce60
9 changed files with 19 additions and 121 deletions

View File

@@ -1,24 +1,15 @@
import importlib.machinery
import importlib.util
import sys
import types
from pathlib import Path
from unittest.mock import MagicMock
ROOT = Path(__file__).resolve().parents[1]
from tests.helpers.cli_loader import load_script
def _load_cli(monkeypatch):
svc = types.ModuleType("services.memory.memory")
svc.MemoryManager = MagicMock()
monkeypatch.setitem(sys.modules, "services.memory.memory", svc)
path = ROOT / "scripts" / "odysseus-memory"
loader = importlib.machinery.SourceFileLoader("odysseus_memory_cli", str(path))
spec = importlib.util.spec_from_loader(loader.name, loader)
module = importlib.util.module_from_spec(spec)
loader.exec_module(module)
return module
return load_script("odysseus-memory")
def test_memory_entries_skips_invalid_rows(monkeypatch):