Move test status structure
This commit is contained in:
parent
d3502ac4d8
commit
daf81305b8
|
@ -40,6 +40,7 @@ if TYPE_CHECKING:
|
||||||
from _pytest.reports import TestReport
|
from _pytest.reports import TestReport
|
||||||
from _pytest.runner import CallInfo
|
from _pytest.runner import CallInfo
|
||||||
from _pytest.terminal import TerminalReporter
|
from _pytest.terminal import TerminalReporter
|
||||||
|
from _pytest.terminal import TestStatus
|
||||||
from _pytest.compat import LEGACY_PATH
|
from _pytest.compat import LEGACY_PATH
|
||||||
|
|
||||||
|
|
||||||
|
@ -805,7 +806,7 @@ def pytest_report_collectionfinish( # type:ignore[empty-body]
|
||||||
@hookspec(firstresult=True)
|
@hookspec(firstresult=True)
|
||||||
def pytest_report_teststatus( # type:ignore[empty-body]
|
def pytest_report_teststatus( # type:ignore[empty-body]
|
||||||
report: Union["CollectReport", "TestReport"], config: "Config"
|
report: Union["CollectReport", "TestReport"], config: "Config"
|
||||||
) -> "TerminalReporter.TestStatus":
|
) -> "TestStatus":
|
||||||
"""Return result-category, shortletter and verbose word for status
|
"""Return result-category, shortletter and verbose word for status
|
||||||
reporting.
|
reporting.
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,21 @@ class MoreQuietAction(argparse.Action):
|
||||||
namespace.quiet = getattr(namespace, "quiet", 0) + 1
|
namespace.quiet = getattr(namespace, "quiet", 0) + 1
|
||||||
|
|
||||||
|
|
||||||
|
class TestStatus(NamedTuple):
|
||||||
|
"""Used to store the test status result category, shortletter and verbose word.
|
||||||
|
For example ``"rerun", "R", ("RERUN", {"yellow": True})``.
|
||||||
|
|
||||||
|
category: the class of result, for example “passed”, “skipped”, “error”, or the empty string
|
||||||
|
letter: the shortletter shown as testing progresses, for example ".", "s", "E", or the empty string.
|
||||||
|
word: verbose word is shown as testing progresses in verbose mode, for example "PASSED", "SKIPPED",
|
||||||
|
"ERROR", or the empty string.
|
||||||
|
"""
|
||||||
|
|
||||||
|
category: str
|
||||||
|
letter: str
|
||||||
|
word: Union[str, Tuple[str, Mapping[str, bool]]]
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser: Parser) -> None:
|
def pytest_addoption(parser: Parser) -> None:
|
||||||
group = parser.getgroup("terminal reporting", "Reporting", after="general")
|
group = parser.getgroup("terminal reporting", "Reporting", after="general")
|
||||||
group._addoption(
|
group._addoption(
|
||||||
|
@ -546,25 +561,11 @@ class TerminalReporter:
|
||||||
self.write_fspath_result(nodeid, "")
|
self.write_fspath_result(nodeid, "")
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
class TestStatus(NamedTuple):
|
|
||||||
"""Used to store the test status result category, shortletter and verbose word.
|
|
||||||
For example ``"rerun", "R", ("RERUN", {"yellow": True})``.
|
|
||||||
|
|
||||||
category: the class of result, for example “passed”, “skipped”, “error”, or the empty string
|
|
||||||
letter: the shortletter shown as testing progresses, for example ".", "s", "E", or the empty string.
|
|
||||||
word: verbose word is shown as testing progresses in verbose mode, for example "PASSED", "SKIPPED",
|
|
||||||
"ERROR", or the empty string.
|
|
||||||
"""
|
|
||||||
|
|
||||||
category: str
|
|
||||||
letter: str
|
|
||||||
word: Union[str, Tuple[str, Mapping[str, bool]]]
|
|
||||||
|
|
||||||
def pytest_runtest_logreport(self, report: TestReport) -> None:
|
def pytest_runtest_logreport(self, report: TestReport) -> None:
|
||||||
self._tests_ran = True
|
self._tests_ran = True
|
||||||
rep = report
|
rep = report
|
||||||
|
|
||||||
res = self.TestStatus(
|
res = TestStatus(
|
||||||
*self.config.hook.pytest_report_teststatus(report=rep, config=self.config)
|
*self.config.hook.pytest_report_teststatus(report=rep, config=self.config)
|
||||||
)
|
)
|
||||||
category, letter, word = res.category, res.letter, res.word
|
category, letter, word = res.category, res.letter, res.word
|
||||||
|
|
Loading…
Reference in New Issue