turn create_result_file into classmethod
This commit is contained in:
parent
016b88a68d
commit
3ffa2f8ecd
1 changed files with 13 additions and 8 deletions
|
|
@ -6,6 +6,8 @@ from typing import TYPE_CHECKING, Callable, NamedTuple
|
|||
import pytest
|
||||
from loguru import logger
|
||||
|
||||
from pytest_abra import DirManager
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pytest_abra.coordinator import Coordinator
|
||||
from pytest_abra.env_manager import EnvFile
|
||||
|
|
@ -89,12 +91,13 @@ class Runner:
|
|||
if not condition_result:
|
||||
# test condition is defined but not met
|
||||
logger.info(f"skipping {identifier_string} (test condition is not met)")
|
||||
self.create_result_file(self.DIR, result="skipped", identifier_string=identifier_string)
|
||||
return
|
||||
|
||||
# test condition is undefined or not met
|
||||
logger.info(f"running {identifier_string}")
|
||||
result = self._call_pytest(full_test_path)
|
||||
self._create_result_file(result=result, identifier_string=identifier_string)
|
||||
self.create_result_file(self.DIR, result=result, identifier_string=identifier_string)
|
||||
|
||||
def _run_condition(self, condition_function: Callable[[ConditionArgs], bool]):
|
||||
"""run the test condition function with multiple arguments"""
|
||||
|
|
@ -174,15 +177,19 @@ class Runner:
|
|||
|
||||
return pytest.main(command_arguments)
|
||||
|
||||
def _create_result_file(
|
||||
self,
|
||||
result: int,
|
||||
@classmethod
|
||||
def create_result_file(
|
||||
cls,
|
||||
DIR: DirManager,
|
||||
result: int | str,
|
||||
identifier_string: str,
|
||||
):
|
||||
"""create result file to indicated passed/failed or skipped test"""
|
||||
|
||||
full_name = self.combine_names(self.result_int_to_str(result), identifier_string)
|
||||
file_path = self.DIR.RESULTS / full_name
|
||||
if isinstance(result, int):
|
||||
result = cls.result_int_to_str(result)
|
||||
full_name = cls.combine_names(result, identifier_string)
|
||||
file_path = DIR.RESULTS / full_name
|
||||
with open(file_path, "w") as _:
|
||||
pass # create empty file
|
||||
|
||||
|
|
@ -204,8 +211,6 @@ class Runner:
|
|||
def result_int_to_str(result_int: int) -> str:
|
||||
"""converts the pytest exit code (int) into a meaningful string"""
|
||||
match result_int:
|
||||
case -1:
|
||||
return "skipped"
|
||||
case 0:
|
||||
return "passed"
|
||||
case _:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue