mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
refactor(tests): reuse CLI loader in more tests (#2571)
This commit is contained in:
committed by
GitHub
parent
ae48ea7064
commit
51e668ce60
@@ -1,19 +1,8 @@
|
||||
import importlib.machinery
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _load_preset_cli():
|
||||
path = Path(__file__).resolve().parent.parent / "scripts" / "odysseus-preset"
|
||||
loader = importlib.machinery.SourceFileLoader("odysseus_preset_invalid_entries", str(path))
|
||||
spec = importlib.util.spec_from_loader(loader.name, loader)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
loader.exec_module(module)
|
||||
return module
|
||||
from tests.helpers.cli_loader import load_script
|
||||
|
||||
|
||||
def test_entry_or_fail_rejects_non_object_entries():
|
||||
cli = _load_preset_cli()
|
||||
cli = load_script("odysseus-preset")
|
||||
|
||||
try:
|
||||
cli._entry_or_fail({"broken": "raw prompt"}, "broken")
|
||||
@@ -24,6 +13,6 @@ def test_entry_or_fail_rejects_non_object_entries():
|
||||
|
||||
|
||||
def test_entry_or_fail_returns_valid_entry():
|
||||
cli = _load_preset_cli()
|
||||
cli = load_script("odysseus-preset")
|
||||
|
||||
assert cli._entry_or_fail({"ok": {"name": "ok"}}, "ok") == {"name": "ok"}
|
||||
|
||||
Reference in New Issue
Block a user