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


Python terminal.TerminalReporter类代码示例

本文整理汇总了Python中_pytest.terminal.TerminalReporter的典型用法代码示例。如果您正苦于以下问题:Python TerminalReporter类的具体用法?Python TerminalReporter怎么用?Python TerminalReporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TerminalReporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pytest_collectreport

 def pytest_collectreport(self, report):
     TerminalReporter.pytest_collectreport(self, report)
     if report.location[0]:
         self.paths_left.append(os.path.join(os.getcwd(), report.location[0]))
     if report.failed:
         self.rewrite("")
         self.print_failure(report)
开发者ID:simudream,项目名称:pytest-sugar,代码行数:7,代码来源:pytest_sugar.py

示例2: __init__

 def __init__(self, reporter):
     TerminalReporter.__init__(self, reporter.config)
     self.writer = self._tw
     self.tests_count = 0
     self.reports = []
     self.skipped = []
     self.failed = []
     self.result = StreamResultToBytes(self.writer._file)
开发者ID:loles,项目名称:pytest-subunit,代码行数:8,代码来源:pytest_subunit.py

示例3: test_internalerror

 def test_internalerror(self, testdir, linecomp):
     modcol = testdir.getmodulecol("def test_one(): pass")
     rep = TerminalReporter(modcol.config, file=linecomp.stringio)
     excinfo = pytest.raises(ValueError, "raise ValueError('hello')")
     rep.pytest_internalerror(excinfo.getrepr())
     linecomp.assert_contains_lines([
         "INTERNALERROR> *ValueError*hello*"
     ])
开发者ID:bubenkoff,项目名称:pytest,代码行数:8,代码来源:test_terminal.py

示例4: pytest_runtest_logreport

    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,代码行数:57,代码来源:gherkin_terminal_reporter.py

示例5: test_writeline

 def test_writeline(self, testdir, linecomp):
     modcol = testdir.getmodulecol("def test_one(): pass")
     rep = TerminalReporter(modcol.config, file=linecomp.stringio)
     rep.write_fspath_result(modcol.nodeid, ".")
     rep.write_line("hello world")
     lines = linecomp.stringio.getvalue().split('\n')
     assert not lines[0]
     assert lines[1].endswith(modcol.name + " .")
     assert lines[2] == "hello world"
开发者ID:bubenkoff,项目名称:pytest,代码行数:9,代码来源:test_terminal.py

示例6: test_rewrite

 def test_rewrite(self, testdir, monkeypatch):
     config = testdir.parseconfig()
     f = py.io.TextIO()
     monkeypatch.setattr(f, "isatty", lambda *args: True)
     tr = TerminalReporter(config, f)
     tr._tw.fullwidth = 10
     tr.write("hello")
     tr.rewrite("hey", erase=True)
     assert f.getvalue() == "hello" + "\r" + "hey" + (6 * " ")
开发者ID:Stranger6667,项目名称:pytest,代码行数:9,代码来源:test_terminal.py

示例7: pytest_collectreport

    def pytest_collectreport(self, report):
        """Report failure during colltion.

        :type report: :py:class:_pytest.runner.CollectReport
        """
        TerminalReporter.pytest_collectreport(self, report)

        if report.failed:
            self.report_failure(report, when='collect')
开发者ID:dset0x,项目名称:invenio-checker,代码行数:9,代码来源:conftest_checker.py

示例8: test_rewrite

 def test_rewrite(self, testdir, monkeypatch):
     config = testdir.parseconfig()
     f = py.io.TextIO()
     monkeypatch.setattr(f, 'isatty', lambda *args: True)
     tr = TerminalReporter(config, f)
     tr.writer.fullwidth = 10
     tr.write('hello')
     tr.rewrite('hey', erase=True)
     assert f.getvalue() == 'hello' + '\r' + 'hey' + (7 * ' ')
开发者ID:cryporchild,项目名称:pytest,代码行数:9,代码来源:test_terminal.py

示例9: __init__

 def __init__(self, reporter):
     TerminalReporter.__init__(self, reporter.config)
     self.writer = self._tw
     self.paths_left = []
     self.tests_count = 0
     self.tests_taken = 0
     self.reports = []
     self.unreported_errors = []
     self.progress_blocks = []
     self.reset_tracked_lines()
开发者ID:Frozenball,项目名称:pytest-sugar,代码行数:10,代码来源:pytest_sugar.py

示例10: test_writeline

 def test_writeline(self, testdir, linecomp):
     modcol = testdir.getmodulecol("def test_one(): pass")
     stringio = py.io.TextIO()
     rep = TerminalReporter(modcol.config, file=linecomp.stringio)
     rep.write_fspath_result(py.path.local("xy.py"), '.')
     rep.write_line("hello world")
     lines = linecomp.stringio.getvalue().split('\n')
     assert not lines[0]
     assert lines[1].endswith("xy.py .")
     assert lines[2] == "hello world"
开发者ID:ProProgrammer,项目名称:pytest,代码行数:10,代码来源:test_terminal.py

示例11: __init__

 def __init__(self, reporter):
     TerminalReporter.__init__(self, reporter.config)
     self.writer = self._tw
     self.paths_left = []
     self.tests_count = 0
     self.tests_taken = 0
     self.current_line = ''
     self.currentfspath2 = ''
     self.time_taken = {}
     self.reports = []
     self.unreported_errors = []
开发者ID:elasti-rans,项目名称:pytest-sugar,代码行数:11,代码来源:pytest_sugar.py

示例12: __init__

 def __init__(self, reporter):
     #pytest_collectreport = self.pytest_collectreport
     TerminalReporter.__init__(self, reporter.config)
     self.writer = self._tw
     self.eta_logger = EtaLogger()
     self.paths_left = []
     self.tests_count = 0
     self.tests_taken = 0
     self.current_line = u''
     self.currentfspath2 = ''
     self.time_taken = {}
     self.reports = []
     self.unreported_errors = []
开发者ID:dscerri,项目名称:pytest-sugar,代码行数:13,代码来源:pytest_sugar.py

示例13: perform_collect_and_run

def perform_collect_and_run(session):
    """Collect and run tests streaming from the redis queue."""
    # This mimics the internal pytest collect loop, but shortened
    # while running tests as soon as they are found.
    term = TerminalReporter(session.config)

    redis_connection = get_redis_connection(session.config)

    redis_list = populate_test_generator(session,
                                         redis_connection)


    default_verbosity = session.config.option.verbose
    hook = session.config.hook
    session._initialpaths = set()
    session._initialparts = []
    session._notfound = []
    session.items = []
    for arg in redis_list:
        term.write(os.linesep)
        parts = session._parsearg(arg)
        session._initialparts.append(parts)
        session._initialpaths.add(parts[0])
        arg = "::".join(map(str, parts))
        session.trace("processing argument", arg)
        session.trace.root.indent += 1
        try:
            for x in session._collect(arg):
                items = session.genitems(x)
                new_items = []
                for item in items:
                    new_items.append(item)

                # HACK ATTACK: This little hack lets us remove the
                # 'collected' and 'collecting' messages while still
                # keeping the default verbosity for the rest of the
                # run...
                session.config.option.verbose = -1
                hook.pytest_collection_modifyitems(session=session,
                                                   config=session.config,
                                                   items=new_items)
                session.config.option.verbose = default_verbosity
                for item in new_items:
                    session.items.append(item)
                    _pytest.runner.pytest_runtest_protocol(item, None)
        except NoMatch:
            # we are inside a make_report hook so
            # we cannot directly pass through the exception
            raise pytest.UsageError("Could not find" + arg)
        session.trace.root.indent -= 1
    return session.items
开发者ID:sabidib,项目名称:pytest-redis,代码行数:51,代码来源:pytest_redis.py

示例14: summary_errors

    def summary_errors(self):
      reports = self.getreports('error')
      if not reports:
        return
      for rep in self.stats['error']:
        name = rep.nodeid.split("/")[-1]
        location = None
        if hasattr(rep, 'location'):
          location, lineno, domain = rep.location

        messages.testSuiteStarted(name, location=fspath_to_url(location))
        messages.testStarted("<noname>", location=fspath_to_url(location))
        TerminalReporter.summary_errors(self)
        messages.testError("<noname>")
        messages.testSuiteFinished(name)
开发者ID:ixcel4prescott,项目名称:USATodaySports,代码行数:15,代码来源:pytest_teamcity.py

示例15: redis_test_generator

def redis_test_generator(config, redis_connection, redis_list_key,
                         backup_list_key=None):
    """A generator that pops and returns test paths from the redis list key."""
    term = TerminalReporter(config)

    val = retrieve_test_from_redis(redis_connection,
                                   redis_list_key,
                                   backup_list_key)

    if val is None:
        term.write("No items in redis list '%s'\n" % redis_list_key)

    while val is not None:
        yield val
        val = retrieve_test_from_redis(redis_connection,
                                       redis_list_key,
                                       backup_list_key)
开发者ID:sabidib,项目名称:pytest-redis,代码行数:17,代码来源:pytest_redis.py


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