refactor(tests): finish shared CLI loader adoption

Test-only refactor continuing #2523. Replaces remaining obvious CLI/script loader boilerplate with tests.helpers.cli_loader.load_script while preserving existing stubs and assertions.
This commit is contained in:
Alexandre Teixeira
2026-06-05 06:00:05 +01:00
committed by GitHub
parent 1f40fbe140
commit 43a101d305
10 changed files with 26 additions and 98 deletions
+2 -10
View File
@@ -4,26 +4,18 @@
description (e.g. a number from a hand-edited/legacy skill store) is truthy, so
`123[:200]` raised TypeError. `_preview_text` coerces non-strings to "".
"""
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):
mod = types.ModuleType("services.memory.skills")
mod.SkillsManager = MagicMock()
monkeypatch.setitem(sys.modules, "services.memory.skills", mod)
path = ROOT / "scripts" / "odysseus-skills"
loader = importlib.machinery.SourceFileLoader("odysseus_skills_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-skills")
def test_preview_text_ignores_non_string(monkeypatch):