mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 17:55:26 -04:00
refactor(tests): reuse CLI loader in more tests (#2571)
This commit is contained in:
committed by
GitHub
parent
ae48ea7064
commit
51e668ce60
@@ -1,25 +1,12 @@
|
||||
import importlib.machinery
|
||||
import importlib.util
|
||||
import io
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def _load_cli():
|
||||
path = ROOT / "scripts" / "odysseus-cookbook"
|
||||
loader = importlib.machinery.SourceFileLoader("odysseus_cookbook_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
|
||||
from tests.helpers.cli_loader import load_script
|
||||
|
||||
|
||||
def test_state_set_rejects_non_object_json(tmp_path, monkeypatch, capsys):
|
||||
cli = _load_cli()
|
||||
cli = load_script("odysseus-cookbook")
|
||||
cli._STATE_PATH = tmp_path / "cookbook_state.json"
|
||||
monkeypatch.setattr(cli.sys, "stdin", io.StringIO("[]"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user