reports: BaseReport.{passed,failed,skipped} more friendly to mypy
Not smart enough to understand the previous code.
This commit is contained in:
parent
5f11a35b99
commit
7d306e9e86
|
@ -65,6 +65,7 @@ class BaseReport:
|
||||||
]
|
]
|
||||||
sections: List[Tuple[str, str]]
|
sections: List[Tuple[str, str]]
|
||||||
nodeid: str
|
nodeid: str
|
||||||
|
outcome: "Literal['passed', 'failed', 'skipped']"
|
||||||
|
|
||||||
def __init__(self, **kw: Any) -> None:
|
def __init__(self, **kw: Any) -> None:
|
||||||
self.__dict__.update(kw)
|
self.__dict__.update(kw)
|
||||||
|
@ -141,9 +142,17 @@ class BaseReport:
|
||||||
content for (prefix, content) in self.get_sections("Captured stderr")
|
content for (prefix, content) in self.get_sections("Captured stderr")
|
||||||
)
|
)
|
||||||
|
|
||||||
passed = property(lambda x: x.outcome == "passed")
|
@property
|
||||||
failed = property(lambda x: x.outcome == "failed")
|
def passed(self) -> bool:
|
||||||
skipped = property(lambda x: x.outcome == "skipped")
|
return self.outcome == "passed"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def failed(self) -> bool:
|
||||||
|
return self.outcome == "failed"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def skipped(self) -> bool:
|
||||||
|
return self.outcome == "skipped"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fspath(self) -> str:
|
def fspath(self) -> str:
|
||||||
|
@ -348,7 +357,7 @@ class CollectReport(BaseReport):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
nodeid: str,
|
nodeid: str,
|
||||||
outcome: "Literal['passed', 'skipped', 'failed']",
|
outcome: "Literal['passed', 'failed', 'skipped']",
|
||||||
longrepr,
|
longrepr,
|
||||||
result: Optional[List[Union[Item, Collector]]],
|
result: Optional[List[Union[Item, Collector]]],
|
||||||
sections: Iterable[Tuple[str, str]] = (),
|
sections: Iterable[Tuple[str, str]] = (),
|
||||||
|
|
|
@ -2230,19 +2230,19 @@ def test_skip_reasons_folding() -> None:
|
||||||
|
|
||||||
ev1 = cast(CollectReport, X())
|
ev1 = cast(CollectReport, X())
|
||||||
ev1.when = "execute"
|
ev1.when = "execute"
|
||||||
ev1.skipped = True
|
ev1.skipped = True # type: ignore[misc]
|
||||||
ev1.longrepr = longrepr
|
ev1.longrepr = longrepr
|
||||||
|
|
||||||
ev2 = cast(CollectReport, X())
|
ev2 = cast(CollectReport, X())
|
||||||
ev2.when = "execute"
|
ev2.when = "execute"
|
||||||
ev2.longrepr = longrepr
|
ev2.longrepr = longrepr
|
||||||
ev2.skipped = True
|
ev2.skipped = True # type: ignore[misc]
|
||||||
|
|
||||||
# ev3 might be a collection report
|
# ev3 might be a collection report
|
||||||
ev3 = cast(CollectReport, X())
|
ev3 = cast(CollectReport, X())
|
||||||
ev3.when = "collect"
|
ev3.when = "collect"
|
||||||
ev3.longrepr = longrepr
|
ev3.longrepr = longrepr
|
||||||
ev3.skipped = True
|
ev3.skipped = True # type: ignore[misc]
|
||||||
|
|
||||||
values = _folded_skips(Path.cwd(), [ev1, ev2, ev3])
|
values = _folded_skips(Path.cwd(), [ev1, ev2, ev3])
|
||||||
assert len(values) == 1
|
assert len(values) == 1
|
||||||
|
|
Loading…
Reference in New Issue