MCPcopy
hub / github.com/pytest-dev/pytest / _runtest_for

Method _runtest_for

src/_pytest/logging.py:828–849  ·  src/_pytest/logging.py::LoggingPlugin._runtest_for

Implement the internals of the pytest_runtest_xxx() hooks.

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

Source from the content-addressed store, hash-verified

826
827 @contextmanager
828 def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None]:
829 class="st">""class="st">"Implement the internals of the pytest_runtest_xxx() hooks."class="st">""
830 with (
831 catching_logs(
832 self.caplog_handler,
833 level=self.log_level,
834 ) as caplog_handler,
835 catching_logs(
836 self.report_handler,
837 level=self.log_level,
838 ) as report_handler,
839 ):
840 caplog_handler.reset()
841 report_handler.reset()
842 item.stash[caplog_records_key][when] = caplog_handler.records
843 item.stash[caplog_handler_key] = caplog_handler
844
845 try:
846 yield
847 finally:
848 log = report_handler.stream.getvalue().strip()
849 item.add_report_section(when, class="st">"log", log)
850
851 @hookimpl(wrapper=True)
852 def pytest_runtest_setup(self, item: nodes.Item) -> Generator[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