logging: yield from _runtest_for instead of contextmanager

Avoid the slight overhead of contextmanager.
This commit is contained in:
Ran Benita 2020-05-17 14:58:04 +03:00
parent 9effbe7425
commit ce0f218793
1 changed files with 6 additions and 13 deletions

View File

@ -625,7 +625,6 @@ class LoggingPlugin:
with catching_logs(logging.NullHandler()):
yield
@contextmanager
def _runtest_for(
self, item: Optional[nodes.Item], when: str
) -> Generator[None, None, None]:
@ -662,35 +661,29 @@ class LoggingPlugin:
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_setup(self, item):
with self._runtest_for(item, "setup"):
yield
yield from self._runtest_for(item, "setup")
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_call(self, item):
with self._runtest_for(item, "call"):
yield
yield from self._runtest_for(item, "call")
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_teardown(self, item):
with self._runtest_for(item, "teardown"):
yield
yield from self._runtest_for(item, "teardown")
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_logstart(self):
if self.log_cli_handler:
self.log_cli_handler.reset()
with self._runtest_for(None, "start"):
yield
yield from self._runtest_for(None, "start")
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_logfinish(self):
with self._runtest_for(None, "finish"):
yield
yield from self._runtest_for(None, "finish")
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_logreport(self):
with self._runtest_for(None, "logreport"):
yield
yield from self._runtest_for(None, "logreport")
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_sessionfinish(self):