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
+2 -13
View File
@@ -1,19 +1,8 @@
import importlib.machinery
import importlib.util
from pathlib import Path
def _load_dispatcher():
path = Path(__file__).resolve().parent.parent / "scripts" / "odysseus"
loader = importlib.machinery.SourceFileLoader("odysseus_dispatcher_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
from tests.helpers.cli_loader import load_script
def test_is_runnable_subcommand_requires_executable_file(tmp_path):
cli = _load_dispatcher()
cli = load_script("odysseus")
sub = tmp_path / "odysseus-demo"
sub.write_text("#!/bin/sh\n")
sub.chmod(0o644)