From 2fe54d031197921212ed887d5e26fb05fc260ac1 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Tue, 22 Jul 2025 15:16:41 +0300 Subject: [PATCH] feat: release version 6.3.7 with skip message handling improvements - Fixed a crash issue with `TypeError: 'ExceptionChainRepr' object is not subscriptable` when handling skip messages in newer pytest versions. - Enhanced the plugin to properly handle both old and new formats of longrepr for skip message extraction. - Updated version to 6.3.7 in pyproject.toml and added changes to the changelog. Fixed #385 --- qase-pytest/changelog.md | 6 ++++++ qase-pytest/pyproject.toml | 2 +- qase-pytest/src/qase/pytest/plugin.py | 28 +++++++++++++++++++++++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/qase-pytest/changelog.md b/qase-pytest/changelog.md index e1e083f3..a7c47735 100644 --- a/qase-pytest/changelog.md +++ b/qase-pytest/changelog.md @@ -1,3 +1,9 @@ +# qase-pytest 6.3.7 + +## What's new + +Fixed an issue where the plugin would crash with `TypeError: 'ExceptionChainRepr' object is not subscriptable` when handling skip messages in newer versions of pytest. The plugin now properly handles both tuple/list format longrepr (old pytest versions) and ExceptionChainRepr format (new pytest versions) for skip message extraction. + # qase-pytest 6.3.6 ## What's new diff --git a/qase-pytest/pyproject.toml b/qase-pytest/pyproject.toml index f63e8f61..5c81d23d 100644 --- a/qase-pytest/pyproject.toml +++ b/qase-pytest/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "qase-pytest" -version = "6.3.6" +version = "6.3.7" description = "Qase Pytest Plugin for Qase TestOps and Qase Report" readme = "README.md" keywords = ["qase", "pytest", "plugin", "testops", "report", "qase reporting", "test observability"] diff --git a/qase-pytest/src/qase/pytest/plugin.py b/qase-pytest/src/qase/pytest/plugin.py index c04a7fe0..323f989a 100644 --- a/qase-pytest/src/qase/pytest/plugin.py +++ b/qase-pytest/src/qase/pytest/plugin.py @@ -173,10 +173,7 @@ def pytest_runtest_makereport(self, item, call): self.runtime.result.add_message(report.wasxfail) # Handle skip message in setup phase - if (call.when == "setup" and - report.longrepr and - self.runtime.result.execution.status == PYTEST_TO_QASE_STATUS['SKIPPED']): - self.runtime.result.add_message(report.longrepr[2].split(":")[1]) + self._handle_skip_message_in_setup(report, call) # Handle Playwright artifacts if applicable if call.when == "call": @@ -232,6 +229,29 @@ def _set_result_status(self, status): """Set test result execution status.""" self.runtime.result.execution.status = status + def _handle_skip_message_in_setup(self, report, call): + """Handle skip message in setup phase with proper longrepr handling.""" + if (call.when == "setup" and + report.longrepr and + self.runtime.result.execution.status == PYTEST_TO_QASE_STATUS['SKIPPED']): + # Handle different types of longrepr + skip_message = None + if hasattr(report.longrepr, '__getitem__'): + # Handle tuple/list format (old pytest versions) + try: + skip_message = report.longrepr[2].split(":")[1] + except (IndexError, AttributeError): + pass + elif hasattr(report.longrepr, 'reprcrash'): + # Handle ExceptionChainRepr format (new pytest versions) + try: + skip_message = str(report.longrepr.reprcrash.message) + except AttributeError: + pass + + if skip_message: + self.runtime.result.add_message(skip_message) + def _attach_logs(self, report): """Attach logs to the test result.""" logs = [