Skip to content

Commit 9df0b2e

Browse files
Fix internal error when processing warnings
Closes #106.
1 parent b811689 commit 9df0b2e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Fix internal error when processing warnings #117
56
- Test on Python 3.14 #115
67

78
## 0.3.0 (2025-01-17)

pytest_github_actions_annotate_failures/plugin.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from packaging import version
1111

1212
if TYPE_CHECKING:
13+
from warnings import WarningMessage
14+
1315
from _pytest.nodes import Item
1416
from _pytest.reports import CollectReport
1517

@@ -98,7 +100,13 @@ def compute_path(filesystempath: str) -> str:
98100

99101

100102
class _AnnotateWarnings:
101-
def pytest_warning_recorded(self, warning_message, when, nodeid, location): # noqa: ARG002
103+
def pytest_warning_recorded(
104+
self,
105+
warning_message: WarningMessage,
106+
when: str,
107+
nodeid: str,
108+
location: tuple[str, int, str],
109+
):
102110
# enable only in a workflow of GitHub Actions
103111
# ref: https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
104112
if os.environ.get("GITHUB_ACTIONS") != "true":
@@ -124,7 +132,7 @@ def pytest_warning_recorded(self, warning_message, when, nodeid, location): # n
124132
"warning",
125133
filesystempath,
126134
warning_message.lineno,
127-
message=warning_message.message.args[0],
135+
message=str(warning_message.message)
128136
)
129137
print(workflow_command, file=sys.stderr)
130138

0 commit comments

Comments
 (0)