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


Python TerminalReporter.write方法代码示例

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


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

示例1: test_rewrite

# 需要导入模块: from _pytest.terminal import TerminalReporter [as 别名]
# 或者: from _pytest.terminal.TerminalReporter import write [as 别名]
 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,代码行数:11,代码来源:test_terminal.py

示例2: test_rewrite

# 需要导入模块: from _pytest.terminal import TerminalReporter [as 别名]
# 或者: from _pytest.terminal.TerminalReporter import write [as 别名]
 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,代码行数:11,代码来源:test_terminal.py

示例3: perform_collect_and_run

# 需要导入模块: from _pytest.terminal import TerminalReporter [as 别名]
# 或者: from _pytest.terminal.TerminalReporter import write [as 别名]
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,代码行数:53,代码来源:pytest_redis.py

示例4: redis_test_generator

# 需要导入模块: from _pytest.terminal import TerminalReporter [as 别名]
# 或者: from _pytest.terminal.TerminalReporter import write [as 别名]
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,代码行数:19,代码来源:pytest_redis.py


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