Define a typing.NamedTuple for TestStatus
This commit is contained in:
parent
df4ca8162b
commit
d126158421
|
@ -4,7 +4,6 @@ from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Mapping
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
@ -806,7 +805,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"
|
||||||
) -> Tuple[str, str, Union[str, Tuple[str, Mapping[str, bool]]]]:
|
) -> "TerminalReporter.TestStatus":
|
||||||
"""Return result-category, shortletter and verbose word for status
|
"""Return result-category, shortletter and verbose word for status
|
||||||
reporting.
|
reporting.
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
import warnings
|
import warnings
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from collections import namedtuple
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
@ -22,6 +21,7 @@ from typing import Dict
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Mapping
|
from typing import Mapping
|
||||||
|
from typing import NamedTuple
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
from typing import Set
|
from typing import Set
|
||||||
|
@ -546,11 +546,16 @@ class TerminalReporter:
|
||||||
self.write_fspath_result(nodeid, "")
|
self.write_fspath_result(nodeid, "")
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
|
class TestStatus(NamedTuple):
|
||||||
|
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 = namedtuple("Res", ["category", "letter", "word"])
|
|
||||||
res = Res(
|
res = self.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