MCPcopy Create free account
hub / github.com/pytest-dev/pytest / _runtest_for

Method _runtest_for

src/_pytest/logging.py:693–710  ·  view source on GitHub ↗

Implement the internals of the pytest_runtest_xxx() hooks.

(self, item: nodes.Item, when: str)

Source from the content-addressed store, hash-verified

691 self.log_cli_handler.set_when("logreport")
692
693 def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None, None, None]:
694 """Implement the internals of the pytest_runtest_xxx() hooks."""
695 with catching_logs(
696 self.caplog_handler,
697 level=self.log_level,
698 ) as caplog_handler, catching_logs(
699 self.report_handler,
700 level=self.log_level,
701 ) as report_handler:
702 caplog_handler.reset()
703 report_handler.reset()
704 item.stash[caplog_records_key][when] = caplog_handler.records
705 item.stash[caplog_handler_key] = caplog_handler
706
707 yield
708
709 log = report_handler.stream.getvalue().strip()
710 item.add_report_section(when, "log", log)
711
712 @hookimpl(hookwrapper=True)
713 def pytest_runtest_setup(self, item: nodes.Item) -> Generator[None, None, None]:

Callers 3

pytest_runtest_setupMethod · 0.95
pytest_runtest_callMethod · 0.95

Calls 5

catching_logsClass · 0.85
stripMethod · 0.80
add_report_sectionMethod · 0.80
resetMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected