add test_runner_runner_dict_import_failing

This commit is contained in:
Daniel 2023-12-15 14:42:45 +01:00
parent b2c9862589
commit d4b6ade31a
2 changed files with 29 additions and 1 deletions

View file

@ -112,6 +112,11 @@ class Coordinator:
load_json_to_environ(test_credentials_path)
@staticmethod
def add_to_sys(path: Path):
# this is a function so that it can be monkeypatched
sys.path.append(path.as_posix())
@staticmethod
def create_runner_dict(recipes_dir: Path) -> dict[str, type[Runner]]:
"""Creates a dictionary holding all the RunnerClasses that can be discovered in recipes_dir
@ -131,7 +136,7 @@ class Coordinator:
runner_discovery_pattern = re.compile("Runner.+")
# make it possible to import modules from recipes_dir
sys.path.append(recipes_dir.as_posix())
Coordinator.add_to_sys(recipes_dir)
for module_path in recipes_dir.rglob("*/runner_*.py"):
rel_path = module_path.relative_to(recipes_dir).as_posix().replace("/", ".").replace(".py", "")