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

Method pytest_runtest_logreport

src/_pytest/terminal.py:625–699  ·  view source on GitHub ↗
(self, report: TestReport)

Source from the content-addressed store, hash-verified

623 self.flush()
624
625 def pytest_runtest_logreport(self, report: TestReport) -> None:
626 self._tests_ran = True
627 rep = report
628
629 res = TestShortLogReport(
630 *self.config.hook.pytest_report_teststatus(report=rep, config=self.config)
631 )
632 category, letter, word = res.category, res.letter, res.word
633 if not isinstance(word, tuple):
634 markup = None
635 else:
636 word, markup = word
637 self._add_stats(category, [rep])
638 if not letter and not word:
639 # Probably passed setup/teardown.
640 return
641 if markup is None:
642 was_xfail = hasattr(report, "wasxfail")
643 if rep.passed and not was_xfail:
644 markup = {"green": True}
645 elif rep.passed and was_xfail:
646 markup = {"yellow": True}
647 elif rep.failed:
648 markup = {"red": True}
649 elif rep.skipped:
650 markup = {"yellow": True}
651 else:
652 markup = {}
653 self._progress_nodeids_reported.add(rep.nodeid)
654 if self.config.get_verbosity(Config.VERBOSITY_TEST_CASES) <= 0:
655 self._tw.write(letter, **markup)
656 # When running in xdist, the logreport and logfinish of multiple
657 # items are interspersed, e.g. `logreport`, `logreport`,
658 # `logfinish`, `logfinish`. To avoid the "past edge" calculation
659 # from getting confused and overflowing (#7166), do the past edge
660 # printing here and not in logfinish, except for the 100% which
661 # should only be printed after all teardowns are finished.
662 if self._show_progress_info and not self._is_last_item:
663 self._write_progress_information_if_past_edge()
664 else:
665 line = self._locationline(rep.nodeid, *rep.location)
666 running_xdist = hasattr(rep, "node")
667 if not running_xdist:
668 self.write_ensure_prefix(line, word, **markup)
669 if rep.skipped or hasattr(report, "wasxfail"):
670 reason = _get_raw_skip_reason(rep)
671 if self.config.get_verbosity(Config.VERBOSITY_TEST_CASES) < 2:
672 available_width = (
673 (self._tw.fullwidth - self._tw.width_of_current_line)
674 - len(" [100%]")
675 - 1
676 )
677 formatted_reason = _format_trimmed(
678 " ({})", reason, available_width
679 )
680 else:
681 formatted_reason = f" ({reason})"
682

Callers

nothing calls this directly

Calls 14

_add_statsMethod · 0.95
_locationlineMethod · 0.95
write_ensure_prefixMethod · 0.95
wrap_writeMethod · 0.95
ensure_newlineMethod · 0.95
flushMethod · 0.95
TestShortLogReportClass · 0.85
_get_raw_skip_reasonFunction · 0.85
_format_trimmedFunction · 0.85

Tested by

no test coverage detected