From 08b9eb5ca41991cd1508e8c628f5091de39b778c Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Tue, 15 Sep 2026 22:11:35 +0100 Subject: [PATCH 1/5] fix hierarchy flags working independently The rp_hierarchy_code flag was overriding rp_hierarchy_dirs and rp_hierarchy_test_file settings. Now these flags work independently so users can enable directory and test file hierarchies while disabling code hierarchy. Fixes issue #409 --- pytest_reportportal/service.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pytest_reportportal/service.py b/pytest_reportportal/service.py index fceb5f44..b6c4e27b 100644 --- a/pytest_reportportal/service.py +++ b/pytest_reportportal/service.py @@ -460,7 +460,12 @@ def _merge_dirs(self, test_tree: dict[str, Any]) -> None: self._merge_leaf_types(test_tree, {LeafType.DIR, LeafType.FILE}, self._config.rp_dir_path_separator) def _merge_code_with_separator(self, test_tree: dict[str, Any], separator: str) -> None: - self._merge_leaf_types(test_tree, {LeafType.CODE, LeafType.FILE, LeafType.DIR, LeafType.SUITE}, separator) + types_to_merge = {LeafType.CODE, LeafType.SUITE} + if not self._config.rp_hierarchy_test_file: + types_to_merge.add(LeafType.FILE) + if not self._config.rp_hierarchy_dirs: + types_to_merge.add(LeafType.DIR) + self._merge_leaf_types(test_tree, types_to_merge, separator) def _merge_code(self, test_tree: dict[str, Any]) -> None: self._merge_code_with_separator(test_tree, "::") From 1581a2e98816cd66ffab5a15abc6e085b9b1fe46 Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Tue, 15 Sep 2026 22:24:04 +0100 Subject: [PATCH 2/5] add test for independent hierarchy flags Test case for issue #409 to verify rp_hierarchy_dirs and rp_hierarchy_test_file work correctly when rp_hierarchy_code is disabled --- tests/integration/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index d57be797..3d59848e 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -35,6 +35,7 @@ + [["examples/hierarchy/inner/test_inner_simple.py"]] * 7 + [["examples/hierarchy/test_in_class_in_class.py"]] + [["examples/test_simple.py"]] * 2 + + [["examples/hierarchy/inner/test_inner_simple.py"]] ) # noinspection PyTypeChecker @@ -65,6 +66,10 @@ dict(**utils.DEFAULT_VARIABLES), dict({"rp_hierarchy_test_file": False}, **utils.DEFAULT_VARIABLES), dict({"rp_hierarchy_test_file": False, "rp_hierarchy_dirs_level": 1}, **utils.DEFAULT_VARIABLES), + dict( + {"rp_hierarchy_dirs": True, "rp_hierarchy_test_file": True, "rp_hierarchy_code": False}, + **utils.DEFAULT_VARIABLES, + ), ] HIERARCHY_TEST_EXPECTED_ITEMS = [ @@ -271,6 +276,13 @@ ], [{"name": "examples::test_simple", "item_type": "STEP", "parent_item_id": lambda x: x is None}], [{"name": "test_simple", "item_type": "STEP", "parent_item_id": lambda x: x is None}], + [ + {"name": "examples", "item_type": "SUITE", "parent_item_id": lambda x: x is None}, + {"name": "hierarchy", "item_type": "SUITE", "parent_item_id": lambda x: x.startswith("examples")}, + {"name": "inner", "item_type": "SUITE", "parent_item_id": lambda x: x.startswith("hierarchy")}, + {"name": "test_inner_simple.py", "item_type": "SUITE", "parent_item_id": lambda x: x.startswith("inner")}, + {"name": "test_simple", "item_type": "STEP", "parent_item_id": lambda x: x.startswith("test_inner_simple.py")}, + ], ] HIERARCHY_TEST_PARAMETERS = [ From c5aed680485476157cf8ad299457bd24ab35d178 Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Tue, 15 Sep 2026 22:25:59 +0100 Subject: [PATCH 3/5] fix BDD scenario handling for hierarchy flags BDD scenarios need FILE to be merged even when rp_hierarchy_test_file is enabled, to produce the correct Feature-Scenario combined name. Added is_bdd parameter to _merge_code_with_separator to handle this case separately from regular test collection. --- pytest_reportportal/service.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytest_reportportal/service.py b/pytest_reportportal/service.py index b6c4e27b..70b6d285 100644 --- a/pytest_reportportal/service.py +++ b/pytest_reportportal/service.py @@ -459,9 +459,9 @@ def _merge_leaf_types(self, test_tree: dict[str, Any], leaf_types: set, separato def _merge_dirs(self, test_tree: dict[str, Any]) -> None: self._merge_leaf_types(test_tree, {LeafType.DIR, LeafType.FILE}, self._config.rp_dir_path_separator) - def _merge_code_with_separator(self, test_tree: dict[str, Any], separator: str) -> None: + def _merge_code_with_separator(self, test_tree: dict[str, Any], separator: str, is_bdd: bool = False) -> None: types_to_merge = {LeafType.CODE, LeafType.SUITE} - if not self._config.rp_hierarchy_test_file: + if is_bdd or not self._config.rp_hierarchy_test_file: types_to_merge.add(LeafType.FILE) if not self._config.rp_hierarchy_dirs: types_to_merge.add(LeafType.DIR) @@ -1190,7 +1190,7 @@ def start_bdd_scenario(self, feature: Feature, scenario: Scenario) -> None: self._generate_names(root_leaf) if not self._config.rp_hierarchy_code: try: - self._merge_code_with_separator(root_leaf, " - ") + self._merge_code_with_separator(root_leaf, " - ", is_bdd=True) except Exception as e: LOGGER.exception(e) self._build_item_paths(root_leaf, []) From b24ac2887517694eadf293ec5353e37193c5ad01 Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Tue, 15 Sep 2026 22:36:43 +0100 Subject: [PATCH 4/5] add docstring to _merge_code_with_separator method Documents the is_bdd parameter and hierarchy flag handling --- pytest_reportportal/service.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pytest_reportportal/service.py b/pytest_reportportal/service.py index 70b6d285..29e4c122 100644 --- a/pytest_reportportal/service.py +++ b/pytest_reportportal/service.py @@ -460,6 +460,12 @@ def _merge_dirs(self, test_tree: dict[str, Any]) -> None: self._merge_leaf_types(test_tree, {LeafType.DIR, LeafType.FILE}, self._config.rp_dir_path_separator) def _merge_code_with_separator(self, test_tree: dict[str, Any], separator: str, is_bdd: bool = False) -> None: + """Merge code and suite leaves, respecting hierarchy flags. + + :param test_tree: Test tree structure to merge + :param separator: Separator to use when merging names + :param is_bdd: If True, always merge FILE for BDD scenarios. Otherwise respect rp_hierarchy_test_file + """ types_to_merge = {LeafType.CODE, LeafType.SUITE} if is_bdd or not self._config.rp_hierarchy_test_file: types_to_merge.add(LeafType.FILE) From 762b8afbdd4966c529949b0c45648f44324db640 Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Tue, 15 Sep 2026 22:40:33 +0100 Subject: [PATCH 5/5] add docstrings to merge methods Document _merge_dirs and _merge_code methods to meet coverage threshold --- pytest_reportportal/service.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pytest_reportportal/service.py b/pytest_reportportal/service.py index 29e4c122..75fa80e0 100644 --- a/pytest_reportportal/service.py +++ b/pytest_reportportal/service.py @@ -457,6 +457,10 @@ def _merge_leaf_types(self, test_tree: dict[str, Any], leaf_types: set, separato self._merge_leaf_types(child_leaf, leaf_types, separator) def _merge_dirs(self, test_tree: dict[str, Any]) -> None: + """Merge directory and file leaves using configured separator. + + :param test_tree: Test tree structure to merge + """ self._merge_leaf_types(test_tree, {LeafType.DIR, LeafType.FILE}, self._config.rp_dir_path_separator) def _merge_code_with_separator(self, test_tree: dict[str, Any], separator: str, is_bdd: bool = False) -> None: @@ -474,6 +478,10 @@ def _merge_code_with_separator(self, test_tree: dict[str, Any], separator: str, self._merge_leaf_types(test_tree, types_to_merge, separator) def _merge_code(self, test_tree: dict[str, Any]) -> None: + """Merge code and suite leaves using double colon separator. + + :param test_tree: Test tree structure to merge + """ self._merge_code_with_separator(test_tree, "::") def _build_item_paths(self, leaf: dict[str, Any], path: list[dict[str, Any]]) -> None: