hookspec: type annotate pytest_runtest_log{start,finish}

This commit is contained in:
Ran Benita 2020-06-14 12:49:05 +03:00
parent bb7b3af9b9
commit 314d00968a
3 changed files with 12 additions and 6 deletions

View File

@ -396,7 +396,9 @@ def pytest_runtest_protocol(
Stops at first non-None result, see :ref:`firstresult` """
def pytest_runtest_logstart(nodeid, location):
def pytest_runtest_logstart(
nodeid: str, location: Tuple[str, Optional[int], str]
) -> None:
""" signal the start of running a single test item.
This hook will be called **before** :func:`pytest_runtest_setup`, :func:`pytest_runtest_call` and
@ -407,7 +409,9 @@ def pytest_runtest_logstart(nodeid, location):
"""
def pytest_runtest_logfinish(nodeid, location):
def pytest_runtest_logfinish(
nodeid: str, location: Tuple[str, Optional[int], str]
) -> None:
""" signal the complete finish of running a single test item.
This hook will be called **after** :func:`pytest_runtest_setup`, :func:`pytest_runtest_call` and

View File

@ -653,12 +653,12 @@ class LoggingPlugin:
yield # run all the tests
@pytest.hookimpl
def pytest_runtest_logstart(self):
def pytest_runtest_logstart(self) -> None:
self.log_cli_handler.reset()
self.log_cli_handler.set_when("start")
@pytest.hookimpl
def pytest_runtest_logreport(self):
def pytest_runtest_logreport(self) -> None:
self.log_cli_handler.set_when("logreport")
def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None, None, None]:

View File

@ -502,7 +502,9 @@ class TerminalReporter:
def pytest_deselected(self, items) -> None:
self._add_stats("deselected", items)
def pytest_runtest_logstart(self, nodeid, location) -> None:
def pytest_runtest_logstart(
self, nodeid: str, location: Tuple[str, Optional[int], str]
) -> None:
# ensure that the path is printed before the
# 1st test of a module starts running
if self.showlongtestinfo:
@ -569,7 +571,7 @@ class TerminalReporter:
assert self._session is not None
return len(self._progress_nodeids_reported) == self._session.testscollected
def pytest_runtest_logfinish(self, nodeid) -> None:
def pytest_runtest_logfinish(self, nodeid: str) -> None:
assert self._session
if self.verbosity <= 0 and self._show_progress_info:
if self._show_progress_info == "count":