From 10866d0458228ffdc22a7403150269532ddf4449 Mon Sep 17 00:00:00 2001 From: "reportportal.io" Date: Wed, 18 Feb 2026 16:15:33 +0000 Subject: [PATCH 1/7] Changelog update --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 098e505..eb0f066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] + +## [5.1.0] ### Added - Official `Python 3.14` support, by @HardNorth ### Changed From e882c7b913941a2e254d9a3d4cffa558c5d063bb Mon Sep 17 00:00:00 2001 From: "reportportal.io" Date: Wed, 18 Feb 2026 16:15:34 +0000 Subject: [PATCH 2/7] Version update --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6cbfb89..9f01a43 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ from setuptools import setup -__version__ = "5.1.0" +__version__ = "5.1.1" def read_file(fname): From 956f81d443ba00fb2e99f47c7b4d7d4d1aece5f8 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 18 Feb 2026 20:01:46 +0300 Subject: [PATCH 3/7] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb0f066..08b5742 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## [5.1.0] ### Added - Official `Python 3.14` support, by @HardNorth +- Behave "error" status support, by @hemanth-kumar-glean ### Changed - Client version updated on [5.7.0](https://github.com/reportportal/client-Python/releases/tag/5.7.0), by @HardNorth ### Removed From e4a07b87295c924a7194e76cd2f5fc1b9663fbb3 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 19 Feb 2026 19:42:14 +0300 Subject: [PATCH 4/7] Logging on Behave "error" status --- CHANGELOG.md | 2 ++ behave_reportportal/behave_agent.py | 52 ++++++++++++++--------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08b5742..dc7bd33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +### Added +- Logging on Behave "error" status, by @HardNorth ## [5.1.0] ### Added diff --git a/behave_reportportal/behave_agent.py b/behave_reportportal/behave_agent.py index ceb588f..b9d7306 100644 --- a/behave_reportportal/behave_agent.py +++ b/behave_reportportal/behave_agent.py @@ -16,6 +16,7 @@ import mimetypes import os import traceback +from collections import defaultdict from functools import wraps from os import PathLike from typing import Any, Callable, Optional, Union @@ -40,6 +41,23 @@ from behave_reportportal.utils import Singleton +STATUS_MAPPINGS: dict[str, str] = defaultdict(lambda: "FAILED") +STATUS_MAPPINGS["passed"] = "PASSED" +STATUS_MAPPINGS["failed"] = "FAILED" +STATUS_MAPPINGS["error"] = "ERROR" +STATUS_MAPPINGS["skipped"] = "SKIPPED" + + +def convert_to_rp_status(behave_status: str) -> str: + """ + Convert behave test result status to ReportPortal status. + + :param behave_status: behave test result status + :return: ReportPortal test result status + """ + return STATUS_MAPPINGS.get(behave_status) + + def check_rp_enabled(func: Callable) -> Callable: """Verify is RP is enabled in config.""" @@ -164,7 +182,7 @@ def finish_feature(self, context: Context, feature: Feature, status: Optional[st self._rp.finish_test_item( item_id=self._feature_id, end_time=timestamp(), - status=status or self.convert_to_rp_status(feature.status.name), + status=status or convert_to_rp_status(feature.status.name), **kwargs, ) @@ -199,14 +217,15 @@ def finish_scenario( """Finish scenario in ReportPortal.""" if scenario.tags and "skip" in scenario.tags: status = "SKIPPED" - if scenario.status.name == "failed": + rp_status = convert_to_rp_status(scenario.status.name) + if rp_status == "FAILED": self._log_skipped_steps(context, scenario) self._log_scenario_exception(scenario) self._log_cleanups(context, "scenario") self._rp.finish_test_item( item_id=self._scenario_id, end_time=timestamp(), - status=status or self.convert_to_rp_status(scenario.status.name), + status=status or rp_status, **kwargs, ) self._log_item_id = self._feature_id @@ -321,12 +340,13 @@ def _build_step_content(step: Step) -> str: return txt def _finish_step_step_based(self, step: Step, status: Optional[str] = None, **kwargs: Any) -> None: - if step.status.name == "failed": + rp_status = convert_to_rp_status(step.status.name) + if rp_status == "FAILED": self._log_step_exception(step, self._step_id) self._rp.finish_test_item( item_id=self._step_id, end_time=timestamp(), - status=status or self.convert_to_rp_status(step.status.name), + status=status or rp_status, **kwargs, ) self._log_item_id = self._scenario_id @@ -340,7 +360,7 @@ def _finish_step_scenario_based(self, step: Step, **kwargs: Any) -> None: level="INFO", **kwargs, ) - if step.status.name == "failed": + if convert_to_rp_status(step.status.name) == "FAILED": self._log_step_exception(step, self._scenario_id) def _log_step_exception(self, step: Step, item_id: Optional[str]) -> None: @@ -506,23 +526,3 @@ def _test_case_id(scenario: Scenario) -> Optional[Any]: return None return tc_id return None - - @staticmethod - def convert_to_rp_status(behave_status: str) -> str: - """ - Convert behave test result status to ReportPortal status. - - :param behave_status: behave test result status - :return: ReportPortal test result status - """ - if behave_status == "passed": - return "PASSED" - elif behave_status == "failed": - return "FAILED" - elif behave_status == "skipped": - return "SKIPPED" - elif behave_status == "error": - return "FAILED" - else: - # todo define what to do - return "PASSED" From 7c8149b0d835b06fafba55b4e620954734c5dd73 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 19 Feb 2026 19:49:04 +0300 Subject: [PATCH 5/7] Fix tests --- CHANGELOG.md | 2 ++ tests/units/test_rp_agent.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc7bd33..368c6ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## [Unreleased] ### Added - Logging on Behave "error" status, by @HardNorth +### Changed +- Unknown statuses now handled as `FAILED`, by @HardNorth ## [5.1.0] ### Added diff --git a/tests/units/test_rp_agent.py b/tests/units/test_rp_agent.py index a02866e..1e6f179 100644 --- a/tests/units/test_rp_agent.py +++ b/tests/units/test_rp_agent.py @@ -23,7 +23,7 @@ from reportportal_client import BatchedRPClient, RPClient, ThreadedRPClient from reportportal_client.logs import MAX_LOG_BATCH_PAYLOAD_SIZE -from behave_reportportal.behave_agent import BehaveAgent, create_rp_service +from behave_reportportal.behave_agent import BehaveAgent, convert_to_rp_status, create_rp_service from behave_reportportal.config import Config, LogLayout from behave_reportportal.utils import Singleton @@ -52,11 +52,11 @@ def clean_instances(): ("passed", "PASSED"), ("skipped", "SKIPPED"), ("failed", "FAILED"), - ("xyz", "PASSED"), + ("xyz", "FAILED"), ], ) def test_convert_to_rp_status(status, expected): - actual = BehaveAgent.convert_to_rp_status(status) + actual = convert_to_rp_status(status) assert actual == expected, f"Incorrect status:\nActual: {actual}\nExpected:{expected}" From 4fcc5934fc0fa9f5ed9f887b2b745e3a6b219d8d Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 19 Feb 2026 19:51:10 +0300 Subject: [PATCH 6/7] Fix tests --- behave_reportportal/behave_agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/behave_reportportal/behave_agent.py b/behave_reportportal/behave_agent.py index b9d7306..43629f0 100644 --- a/behave_reportportal/behave_agent.py +++ b/behave_reportportal/behave_agent.py @@ -55,7 +55,7 @@ def convert_to_rp_status(behave_status: str) -> str: :param behave_status: behave test result status :return: ReportPortal test result status """ - return STATUS_MAPPINGS.get(behave_status) + return STATUS_MAPPINGS[behave_status] def check_rp_enabled(func: Callable) -> Callable: From a7eeb7aa5bb0ca0ba4221eb4939470695d23c55d Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 19 Feb 2026 19:52:49 +0300 Subject: [PATCH 7/7] Fix isort --- behave_reportportal/behave_agent.py | 1 - 1 file changed, 1 deletion(-) diff --git a/behave_reportportal/behave_agent.py b/behave_reportportal/behave_agent.py index 43629f0..1359274 100644 --- a/behave_reportportal/behave_agent.py +++ b/behave_reportportal/behave_agent.py @@ -40,7 +40,6 @@ from behave_reportportal.config import Config, LogLayout from behave_reportportal.utils import Singleton - STATUS_MAPPINGS: dict[str, str] = defaultdict(lambda: "FAILED") STATUS_MAPPINGS["passed"] = "PASSED" STATUS_MAPPINGS["failed"] = "FAILED"