How to use the py.io.TerminalWriter function in py

To help you get started, we’ve selected a few py examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pytest-dev / pytest / src / _pytest / reports.py View on Github external
def longreprtext(self):
        """
        Read-only property that returns the full string representation
        of ``longrepr``.

        .. versionadded:: 3.0
        """
        tw = py.io.TerminalWriter(stringio=True)
        tw.hasmarkup = False
        self.toterminal(tw)
        exc = tw.stringio.getvalue()
        return exc.strip()
github pytest-dev / pytest / testing / io_ / test_terminalwriter.py View on Github external
def test_terminalwriter_default_instantiation():
    tw = py.io.TerminalWriter(stringio=True)
    assert hasattr(tw, 'stringio')
github pytest-dev / pytest / src / _pytest / config / __init__.py View on Github external
def create_terminal_writer(config, *args, **kwargs):
    """Create a TerminalWriter instance configured according to the options
    in the config object. Every code which requires a TerminalWriter object
    and has access to a config object should use this function.
    """
    tw = py.io.TerminalWriter(*args, **kwargs)
    if config.option.color == "yes":
        tw.hasmarkup = True
    if config.option.color == "no":
        tw.hasmarkup = False
    return tw
github devpi / devpi / server / test_devpi_server / test_gendeploy.py View on Github external
def test_create_devpictl(tmpdir):
    tw = py.io.TerminalWriter()
    devpiserver = tmpdir.ensure("bin", "devpi-server")
    devpiserver.write("FIRST LINE\n")
    devpictl = gendeploy.create_devpictl(tw, tmpdir, httpport=18)
    assert devpictl.check()
    assert devpictl.stat().mode & py.std.stat.S_IXUSR
    firstline = devpictl.readlines(cr=0)[0]
    assert firstline == "FIRST LINE"
github catboost / catboost / library / python / pytest / plugins / ya.py View on Github external
def colorize(longrepr):
    # use default pytest colorization
    if pytest.config.option.tbstyle != "short":
        io = py.io.TextIO()
        writer = py.io.TerminalWriter(file=io)
        # enable colorization
        writer.hasmarkup = True

        if hasattr(longrepr, 'reprtraceback') and hasattr(longrepr.reprtraceback, 'toterminal'):
            longrepr.reprtraceback.toterminal(writer)
            return io.getvalue().strip()
        return yatest_lib.tools.to_utf8(longrepr)

    text = yatest_lib.tools.to_utf8(longrepr)
    pos = text.find("E   ")
    if pos == -1:
        return text

    bt, error = text[:pos], text[pos:]
    filters = [
        # File path, line number and function name
github taverntesting / tavern / tavern / testutils / pytesthook / error.py View on Github external
def longreprtext(self):
        tw = py.io.TerminalWriter(stringio=True)  # pylint: disable=no-member
        tw.hasmarkup = False
        self.toterminal(tw)
        exc = tw.stringio.getvalue()
        return exc.strip()
github KimiNewt / pyshark / src / pyshark / packet / layer.py View on Github external
def pretty_print(self):
        tw = py.io.TerminalWriter()
        if self.layer_name == self.DATA_LAYER:
            tw.write('DATA')
            return

        tw.write('Layer %s:' % self.layer_name.upper() + os.linesep, yellow=True, bold=True)
        for field_line in self._get_all_field_lines():
            if ':' in field_line:
                field_name, field_line = field_line.split(':', 1)
                tw.write(field_name + ':', green=True, bold=True)
            tw.write(field_line, bold=True)
github tox-dev / tox / src / tox / session.py View on Github external
def show_help_ini(config):
    tw = py.io.TerminalWriter()
    tw.sep("-", "per-testenv attributes")
    for env_attr in config._testenv_attr:
        tw.line(
            "{:<15} {:<8} default: {}".format(
                env_attr.name, "<{}>".format(env_attr.type), env_attr.default
            ),
            bold=True,
        )
        tw.line(env_attr.help)
        tw.line()
github devpi / devpi / server / devpi_server / gendeploy.py View on Github external
def gendeploycfg(config, venvdir, tw=None):
    """ generate etc/ structure with supervisord.conf for running
    devpi-server under supervisor control. """
    if tw is None:
        tw = py.io.TerminalWriter()
        tw.cwd = py.path.local()

    #tw.line("creating etc/ directory for supervisor configuration", bold=True)
    etc = venvdir.ensure("etc", dir=1)
    orig_args = list(config.args._raw)

    # filter out --gendeploy option
    for i, val in enumerate(orig_args):
        if val.startswith("--gendeploy="):
            del orig_args[i]
            break
        elif val == "--gendeploy":
            del orig_args[i:i+2]
            break

    if not config.args.serverdir:  # default
github tox-dev / tox / tox / session.py View on Github external
def show_help_ini(config):
    tw = py.io.TerminalWriter()
    tw.sep("-", "per-testenv attributes")
    for env_attr in config._testenv_attr:
        tw.line("%-15s %-8s default: %s" %
                (env_attr.name, "<" + env_attr.type + ">", env_attr.default), bold=True)
        tw.line(env_attr.help)
        tw.line()