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

View File

@@ -1,10 +1,9 @@
import importlib.machinery
import importlib.util
import sys
from pathlib import Path
from types import ModuleType
from types import SimpleNamespace
from tests.helpers.cli_loader import load_script
def _load_sessions_cli(monkeypatch):
core_mod = ModuleType("core")
@@ -13,13 +12,7 @@ def _load_sessions_cli(monkeypatch):
database_mod.Session = object
monkeypatch.setitem(sys.modules, "core", core_mod)
monkeypatch.setitem(sys.modules, "core.database", database_mod)
path = Path(__file__).resolve().parent.parent / "scripts" / "odysseus-sessions"
loader = importlib.machinery.SourceFileLoader("odysseus_sessions_cli_under_test", 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-sessions")
def test_serialize_normalizes_numeric_counters(monkeypatch):