pass coordinator to runner -> much more information available
This commit is contained in:
parent
f9c21c6e6b
commit
813804e33a
2 changed files with 16 additions and 9 deletions
|
|
@ -42,12 +42,12 @@ class Coordinator:
|
||||||
def _load_runners(self, env_files: list[EnvFile]) -> list[Runner]:
|
def _load_runners(self, env_files: list[EnvFile]) -> list[Runner]:
|
||||||
"""Creates an instance of the correct Runner class for each given env file"""
|
"""Creates an instance of the correct Runner class for each given env file"""
|
||||||
runners: list[Runner] = []
|
runners: list[Runner] = []
|
||||||
for env_file in env_files:
|
for index, env_file in enumerate(env_files):
|
||||||
RunnerClass = self.RUNNER_DICT[env_file.config["TYPE"]]
|
RunnerClass = self.RUNNER_DICT[env_file.config["TYPE"]]
|
||||||
dependency_classes: list[type[Runner]] = []
|
dependency_classes: list[type[Runner]] = []
|
||||||
for dependency in RunnerClass.dependencies:
|
for dependency in RunnerClass.dependencies:
|
||||||
dependency_classes.append(self.RUNNER_DICT[dependency])
|
dependency_classes.append(self.RUNNER_DICT[dependency])
|
||||||
runner_instance = RunnerClass(dotenv_path=env_file.env_path, DIR=self.DIR)
|
runner_instance = RunnerClass(coordinator=self, runner_index=index)
|
||||||
runner_instance._dependency_runners = dependency_classes
|
runner_instance._dependency_runners = dependency_classes
|
||||||
runners.append(runner_instance)
|
runners.append(runner_instance)
|
||||||
return runners
|
return runners
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable
|
from typing import TYPE_CHECKING, Callable
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from dotenv import dotenv_values
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from abratest.dir_manager import DirManager
|
if TYPE_CHECKING:
|
||||||
|
from abratest.coordinator import Coordinator
|
||||||
|
from abratest.env_manager import EnvFile
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
@ -25,10 +26,16 @@ class Runner:
|
||||||
dependencies: list[str] = []
|
dependencies: list[str] = []
|
||||||
_dependency_runners: list[type["Runner"]] = []
|
_dependency_runners: list[type["Runner"]] = []
|
||||||
|
|
||||||
def __init__(self, dotenv_path: Path, DIR: DirManager):
|
def __init__(self, coordinator: "Coordinator", runner_index: int):
|
||||||
self.dotenv_path = dotenv_path
|
self.coordinator = coordinator # needed?
|
||||||
self.config: dict[str, str] = dotenv_values(dotenv_path) # type: ignore
|
self.runner_index = runner_index # needed?
|
||||||
self.DIR = DIR
|
|
||||||
|
self.DIR = coordinator.DIR
|
||||||
|
self.ENV = coordinator.ENV
|
||||||
|
|
||||||
|
self.env_file: EnvFile = self.ENV.env_files[self.runner_index]
|
||||||
|
self.dotenv_path = self.env_file.env_path
|
||||||
|
self.config = self.env_file.config
|
||||||
|
|
||||||
logger.info(f"creating instance of {self.__class__.__name__}")
|
logger.info(f"creating instance of {self.__class__.__name__}")
|
||||||
assert self.test_dir_name
|
assert self.test_dir_name
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue