diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index bcd40fb36..c78d54239 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -65,6 +65,7 @@ class BaseReport: ] sections: List[Tuple[str, str]] nodeid: str + outcome: "Literal['passed', 'failed', 'skipped']" def __init__(self, **kw: Any) -> None: self.__dict__.update(kw) @@ -141,9 +142,17 @@ class BaseReport: content for (prefix, content) in self.get_sections("Captured stderr") ) - passed = property(lambda x: x.outcome == "passed") - failed = property(lambda x: x.outcome == "failed") - skipped = property(lambda x: x.outcome == "skipped") + @property + def passed(self) -> bool: + return self.outcome == "passed" + + @property + def failed(self) -> bool: + return self.outcome == "failed" + + @property + def skipped(self) -> bool: + return self.outcome == "skipped" @property def fspath(self) -> str: @@ -348,7 +357,7 @@ class CollectReport(BaseReport): def __init__( self, nodeid: str, - outcome: "Literal['passed', 'skipped', 'failed']", + outcome: "Literal['passed', 'failed', 'skipped']", longrepr, result: Optional[List[Union[Item, Collector]]], sections: Iterable[Tuple[str, str]] = (), diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 6d0a23fe0..e536f7098 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -2230,19 +2230,19 @@ def test_skip_reasons_folding() -> None: ev1 = cast(CollectReport, X()) ev1.when = "execute" - ev1.skipped = True + ev1.skipped = True # type: ignore[misc] ev1.longrepr = longrepr ev2 = cast(CollectReport, X()) ev2.when = "execute" ev2.longrepr = longrepr - ev2.skipped = True + ev2.skipped = True # type: ignore[misc] # ev3 might be a collection report ev3 = cast(CollectReport, X()) ev3.when = "collect" ev3.longrepr = longrepr - ev3.skipped = True + ev3.skipped = True # type: ignore[misc] values = _folded_skips(Path.cwd(), [ev1, ev2, ev3]) assert len(values) == 1