diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dec961..c733feb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Fix internal error when processing warnings #117 - Test on Python 3.14 #115 ## 0.3.0 (2025-01-17) diff --git a/pytest_github_actions_annotate_failures/plugin.py b/pytest_github_actions_annotate_failures/plugin.py index 3f58b95..7f2f4cf 100644 --- a/pytest_github_actions_annotate_failures/plugin.py +++ b/pytest_github_actions_annotate_failures/plugin.py @@ -10,6 +10,8 @@ from packaging import version if TYPE_CHECKING: + from warnings import WarningMessage + from _pytest.nodes import Item from _pytest.reports import CollectReport @@ -98,7 +100,13 @@ def compute_path(filesystempath: str) -> str: class _AnnotateWarnings: - def pytest_warning_recorded(self, warning_message, when, nodeid, location): # noqa: ARG002 + def pytest_warning_recorded( + self, + warning_message: WarningMessage, + when: str, # noqa: ARG002 + nodeid: str, # noqa: ARG002 + location: tuple[str, int, str], # noqa: ARG002 + ): # enable only in a workflow of GitHub Actions # ref: https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables if os.environ.get("GITHUB_ACTIONS") != "true": @@ -124,7 +132,7 @@ def pytest_warning_recorded(self, warning_message, when, nodeid, location): # n "warning", filesystempath, warning_message.lineno, - message=warning_message.message.args[0], + message=str(warning_message.message), ) print(workflow_command, file=sys.stderr)