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]:
|
||||
"""Creates an instance of the correct Runner class for each given env file"""
|
||||
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"]]
|
||||
dependency_classes: list[type[Runner]] = []
|
||||
for dependency in RunnerClass.dependencies:
|
||||
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
|
||||
runners.append(runner_instance)
|
||||
return runners
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Callable
|
||||
from typing import TYPE_CHECKING, Callable
|
||||
|
||||
import pytest
|
||||
from dotenv import dotenv_values
|
||||
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
|
||||
|
|
@ -25,10 +26,16 @@ class Runner:
|
|||
dependencies: list[str] = []
|
||||
_dependency_runners: list[type["Runner"]] = []
|
||||
|
||||
def __init__(self, dotenv_path: Path, DIR: DirManager):
|
||||
self.dotenv_path = dotenv_path
|
||||
self.config: dict[str, str] = dotenv_values(dotenv_path) # type: ignore
|
||||
self.DIR = DIR
|
||||
def __init__(self, coordinator: "Coordinator", runner_index: int):
|
||||
self.coordinator = coordinator # needed?
|
||||
self.runner_index = runner_index # needed?
|
||||
|
||||
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__}")
|
||||
assert self.test_dir_name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue