Use RunnerMeta to save path along with Runner subclass

This commit is contained in:
Daniel 2023-12-10 23:53:49 +01:00
parent 4f8bceb587
commit 7ec75cd6a0
3 changed files with 21 additions and 20 deletions

View file

@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, NamedTuple
from dotenv import dotenv_values
if TYPE_CHECKING:
from pytest_abra.coordinator import RunnerMeta
from pytest_abra.dir_manager import DirManager
from pytest_abra.runner import Runner
@ -24,7 +25,7 @@ class DependencyRule(NamedTuple):
class EnvManager:
def __init__(self, env_paths: list[Path], RUNNER_DICT: dict[str, type["Runner"]]):
def __init__(self, env_paths: list[Path], RUNNER_DICT: dict[str, "RunnerMeta"]):
self.env_files: list[EnvFile] = self._get_env_files(env_paths)
self.dependency_rules: list[DependencyRule] = self._get_dependency_rules(self.env_files, RUNNER_DICT)
self.env_files = self.sort_env_files_by_rule(self.env_files, self.dependency_rules)
@ -42,10 +43,10 @@ class EnvManager:
return env_files
@staticmethod
def _get_dependency_rules(env_files: list[EnvFile], RUNNER_DICT: dict[str, type["Runner"]]) -> list[DependencyRule]:
def _get_dependency_rules(env_files: list[EnvFile], RUNNER_DICT: dict[str, "RunnerMeta"]) -> list[DependencyRule]:
dependency_rules: list[DependencyRule] = []
for env_file in env_files:
child_runner_class = RUNNER_DICT[env_file.env_type]
child_runner_class = RUNNER_DICT[env_file.env_type].cls
for dependency in child_runner_class.dependencies:
dependency_rule = DependencyRule(child=child_runner_class.env_type, dependency=dependency)
dependency_rules.append(dependency_rule)