From 131477557da2489b79298be541a1fc1d016309a2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 11 Dec 2023 12:03:31 +0100 Subject: [PATCH] more refactoring --- pytest_abra/runner.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pytest_abra/runner.py b/pytest_abra/runner.py index 5667cd9..1951cce 100644 --- a/pytest_abra/runner.py +++ b/pytest_abra/runner.py @@ -114,7 +114,8 @@ class Runner: status = cls.exit_code_to_str(status) # remove matching files - [f.unlink() for f in DIR.STATUS.glob("*") if identifier_string in f.name] + for status_file in cls._get_status_files(DIR, identifier_string): + status_file.unlink() full_name = cls.combine_names(status, identifier_string) file_path = DIR.STATUS / full_name @@ -122,10 +123,14 @@ class Runner: pass # create empty file @staticmethod - def _is_test_passed(DIR: "DirManager", identifier_string: str) -> bool: + def _get_status_files(DIR: "DirManager", identifier_string: str) -> list[Path]: + return [f for f in DIR.STATUS.glob("*") if identifier_string in f.name] + + @classmethod + def _is_test_passed(cls, DIR: "DirManager", identifier_string: str) -> bool: """returns True if the selected test matching identifier_string already passed""" - matching_files = [f for f in DIR.STATUS.glob("*") if identifier_string in f.name] + matching_files = cls._get_status_files(DIR, identifier_string) if len(matching_files) == 1: status_file = matching_files[0] if "passed" in status_file.name: