diff --git a/trcli/readers/file_parser.py b/trcli/readers/file_parser.py index 5885408..f839433 100644 --- a/trcli/readers/file_parser.py +++ b/trcli/readers/file_parser.py @@ -15,6 +15,12 @@ def __init__(self, environment: Environment): self.filepath = self.check_file(environment.file) self.filename = self.filepath.name self.env = environment + self._case_result_statuses = {} + + def _update_with_custom_statuses(self): + custom_statuses = self.env.params_from_config.get("case_result_statuses", None) + if custom_statuses: + self._case_result_statuses.update(custom_statuses) @staticmethod def check_file(filepath: Union[str, Path]) -> Path: diff --git a/trcli/readers/junit_xml.py b/trcli/readers/junit_xml.py index 65cd9cc..e99a294 100644 --- a/trcli/readers/junit_xml.py +++ b/trcli/readers/junit_xml.py @@ -91,11 +91,6 @@ def _extract_section_properties(section, processed_props) -> List[TestRailProper return properties - def _update_with_custom_statuses(self): - custom_statuses = self.env.params_from_config.get("case_result_statuses", None) - if custom_statuses: - self._case_result_statuses.update(custom_statuses) - def _extract_case_id_and_name(self, case) -> tuple: case_name = case.name case_id = None diff --git a/trcli/readers/robot_xml.py b/trcli/readers/robot_xml.py index 72e5088..7878ed1 100644 --- a/trcli/readers/robot_xml.py +++ b/trcli/readers/robot_xml.py @@ -22,6 +22,8 @@ class RobotParser(FileParser): def __init__(self, environment: Environment): super().__init__(environment) self.case_matcher = environment.case_matcher + self._case_result_statuses = {"pass": 1, "not run": 3, "skip": 4, "fail": 5} + self._update_with_custom_statuses() @staticmethod def check_file(filepath: Union[str, Path]) -> Path: @@ -131,8 +133,7 @@ def _find_suites(self, suite_element, sections_list: List, namespace=""): if line.lower().startswith("- testrail_case_field"): case_fields.append(self._remove_tr_prefix(line, "- testrail_case_field:")) status = test.find("status") - status_dict = {"pass": 1, "not run": 3, "skip": 4, "fail": 5} - status_id = status_dict[status.get("status").lower()] + status_id = self._case_result_statuses[status.get("status").lower()] elapsed_time = None # if status contains "elapsed" then obtain it, otherwise calculate it from starttime and endtime @@ -149,7 +150,7 @@ def _find_suites(self, suite_element, sections_list: List, namespace=""): for kw in keywords: kw_result = kw.find("status").get("status") step = TestRailSeparatedStep(kw.get("name")) - step.status_id = status_dict[kw_result.lower()] + step.status_id = self._case_result_statuses[kw_result.lower()] step_keywords.append(step) result_fields_dict, error = FieldsParser.resolve_fields(result_fields)