当前位置: 首页>>代码示例>>Python>>正文


Python TerminalReporter.pytest_runtest_logreport方法代码示例

本文整理汇总了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)
开发者ID:Rain0193,项目名称:pytest-bdd,代码行数:59,代码来源:gherkin_terminal_reporter.py


注:本文中的_pytest.terminal.TerminalReporter.pytest_runtest_logreport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。