本文整理汇总了Python中_pytest.terminal.TerminalReporter.pytest_runtest_logreport方法的典型用法代码示例。如果您正苦于以下问题:Python TerminalReporter.pytest_runtest_logreport方法的具体用法?Python TerminalReporter.pytest_runtest_logreport怎么用?Python TerminalReporter.pytest_runtest_logreport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_pytest.terminal.TerminalReporter
的用法示例。
在下文中一共展示了TerminalReporter.pytest_runtest_logreport方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pytest_runtest_logreport
# 需要导入模块: from _pytest.terminal import TerminalReporter [as 别名]
# 或者: from _pytest.terminal.TerminalReporter import pytest_runtest_logreport [as 别名]
def pytest_runtest_logreport(self, report):
rep = report
res = self.config.hook.pytest_report_teststatus(report=rep)
cat, letter, word = res
if not letter and not word:
# probably passed setup/teardown
return
if isinstance(word, tuple):
word, word_markup = word
else:
if rep.passed:
word_markup = {'green': True}
elif rep.failed:
word_markup = {'red': True}
elif rep.skipped:
word_markup = {'yellow': True}
feature_markup = {'blue': True}
scenario_markup = word_markup
if self.verbosity <= 0:
return TerminalReporter.pytest_runtest_logreport(self, rep)
elif self.verbosity == 1:
if hasattr(report, 'scenario'):
self.ensure_newline()
self._tw.write('Feature: ', **feature_markup)
self._tw.write(report.scenario['feature']['name'], **feature_markup)
self._tw.write('\n')
self._tw.write(' Scenario: ', **scenario_markup)
self._tw.write(report.scenario['name'], **scenario_markup)
self._tw.write(' ')
self._tw.write(word, **word_markup)
self._tw.write('\n')
else:
return TerminalReporter.pytest_runtest_logreport(self, rep)
elif self.verbosity > 1:
if hasattr(report, 'scenario'):
self.ensure_newline()
self._tw.write('Feature: ', **feature_markup)
self._tw.write(report.scenario['feature']['name'], **feature_markup)
self._tw.write('\n')
self._tw.write(' Scenario: ', **scenario_markup)
self._tw.write(report.scenario['name'], **scenario_markup)
self._tw.write('\n')
for step in report.scenario['steps']:
if self.config.option.expand:
step_name = self._format_step_name(step['name'], **report.scenario['example_kwargs'])
else:
step_name = step['name']
self._tw.write(' {} {}\n'.format(step['keyword'],
step_name), **scenario_markup)
self._tw.write(' ' + word, **word_markup)
self._tw.write('\n\n')
else:
return TerminalReporter.pytest_runtest_logreport(self, rep)
self.stats.setdefault(cat, []).append(rep)