Skip to content

Commit 4056433

Browse files
authored
Fix type hints for TestReport.when and TestReport.location (#13345)
These are set in `TestReport.__init__` but weren't being picked up by type checkers because of the annotations on `BaseReport`. Fixes #12941.
1 parent 9a7dbd8 commit 4056433

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

changelog/13345.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix type hints for :attr:`pytest.TestReport.when` and :attr:`pytest.TestReport.location`.

src/_pytest/reports.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ class TestReport(BaseReport):
260260
"""
261261

262262
__test__ = False
263+
264+
when: Literal["setup", "call", "teardown"]
265+
location: tuple[str, int | None, str]
263266
# Defined by skipping plugin.
264267
# xfail reason if xfailed, otherwise not defined. Use hasattr to distinguish.
265268
wasxfail: str

0 commit comments

Comments
 (0)