This commit is contained in:
Daniel 2023-12-11 00:07:53 +01:00
parent edc8c9a2f5
commit de6a71b9c8
3 changed files with 7 additions and 7 deletions

View file

@ -109,6 +109,6 @@ class Coordinator:
assert len(runner_class_names) == 1
runner_class_name = runner_class_names[0]
RunnerClass: type[Runner] = getattr(module, runner_class_name)
RunnerClass._tests_path = module_path
RunnerClass._tests_path = module_path.parent
RUNNER_DICT[RunnerClass.env_type] = RunnerClass
return RUNNER_DICT

View file

@ -24,7 +24,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, type["Runner"]]):
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,7 +42,7 @@ 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, type["Runner"]]) -> list[DependencyRule]:
dependency_rules: list[DependencyRule] = []
for env_file in env_files:
child_runner_class = RUNNER_DICT[env_file.env_type]

View file

@ -1,7 +1,7 @@
import os
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Callable, NamedTuple, Optional
from typing import TYPE_CHECKING, Callable, NamedTuple
import pytest
from loguru import logger
@ -31,7 +31,7 @@ class Runner:
tests: list[Test] = []
cleanups: list[Test] = []
dependencies: list[str] = []
_tests_path: Optional[Path] = None
_tests_path: Path = Path("undefined")
def __init__(self, coordinator: "Coordinator", runner_index: int):
self.coordinator = coordinator
@ -74,7 +74,7 @@ class Runner:
identifier_string = self.combine_names(self.env_type, test.test_file)
results = list(self.DIR.RECIPES.rglob(test.test_file))
results = list(self._tests_path.rglob(test.test_file))
assert len(results) == 1, f"{test.test_file} should exist exactly 1 time, but found {len(results)} times"
full_test_path = results[0]
@ -201,7 +201,7 @@ class Runner:
passed_tests = [r.name for r in self.DIR.RESULTS.glob("*") if "passed" in r.name]
results = []
for dependency in self.dependencies:
dependency_runner = self.coordinator.RUNNER_DICT[dependency].cls
dependency_runner = self.coordinator.RUNNER_DICT[dependency]
for setup_name in dependency_runner.setups:
dependencie_identifier = self.combine_names(dependency_runner.env_type, setup_name.test_file)
results.append(any(dependencie_identifier in f for f in passed_tests))