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


Python MeteredStream.update方法代码示例

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


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

示例1: test_regular

# 需要导入模块: from webkitpy.layout_tests.views.metered_stream import MeteredStream [as 别名]
# 或者: from webkitpy.layout_tests.views.metered_stream.MeteredStream import update [as 别名]
    def test_regular(self):
        a = StringIO.StringIO()
        m = MeteredStream(a)
        self.assertFalse(a.getvalue())

        # basic test
        m.write("foo")
        exp = ['foo']
        self.assertEquals(a.buflist, exp)

        # now check that a second write() does not overwrite the first.
        m.write("bar")
        exp.append('bar')
        self.assertEquals(a.buflist, exp)

        m.update("batter")
        exp.append('batter')
        self.assertEquals(a.buflist, exp)

        # The next update() should overwrite the laste update() but not the
        # other text. Note that the cursor is effectively positioned at the
        # end of 'foo', even though we had to erase three more characters.
        m.update("foo")
        exp.append('\b\b\b\b\b\b      \b\b\b\b\b\b')
        exp.append('foo')
        self.assertEquals(a.buflist, exp)

        # now check that a write() does overwrite the update
        m.write("foo")
        exp.append('\b\b\b   \b\b\b')
        exp.append('foo')
        self.assertEquals(a.buflist, exp)

        # Now test that we only back up to the most recent newline.

        # Note also that we do not back up to erase the most recent write(),
        # i.e., write()s do not get erased.
        a = StringIO.StringIO()
        m = MeteredStream(a)
        m.update("foo\nbar")
        m.update("baz")
        self.assertEquals(a.buflist, ['foo\nbar', '\b\b\b   \b\b\b', 'baz'])
开发者ID:,项目名称:,代码行数:44,代码来源:

示例2: Printer

# 需要导入模块: from webkitpy.layout_tests.views.metered_stream import MeteredStream [as 别名]
# 或者: from webkitpy.layout_tests.views.metered_stream.MeteredStream import update [as 别名]
class Printer(object):
    """Class handling all non-debug-logging printing done by run-webkit-tests.

    Printing from run-webkit-tests falls into two buckets: general or
    regular output that is read only by humans and can be changed at any
    time, and output that is parsed by buildbots (and humans) and hence
    must be changed more carefully and in coordination with the buildbot
    parsing code (in chromium.org's buildbot/master.chromium/scripts/master/
    log_parser/webkit_test_command.py script).

    By default the buildbot-parsed code gets logged to stdout, and regular
    output gets logged to stderr."""

    def __init__(self, port, options, regular_output, buildbot_output, configure_logging):
        """
        Args
          port               interface to port-specific routines
          options            OptionParser object with command line settings
          regular_output     stream to which output intended only for humans
                             should be written
          buildbot_output    stream to which output intended to be read by
                             the buildbots (and humans) should be written
          configure_loggign  Whether a logging handler should be registered

        """
        self._port = port
        self._options = options
        self._stream = regular_output
        self._buildbot_stream = buildbot_output
        self._meter = None

        # These are used for --print one-line-progress
        self._last_remaining = None
        self._last_update_time = None

        self.switches = parse_print_options(options.print_options, options.verbose)

        self._logging_handler = None
        if self._stream.isatty() and not options.verbose:
            self._update_interval_seconds = FAST_UPDATES_SECONDS
            self._meter = MeteredStream(self._stream)
            if configure_logging:
                self._logging_handler = _configure_logging(self._meter, options.verbose)
        else:
            self._update_interval_seconds = SLOW_UPDATES_SECONDS
            if configure_logging:
                self._logging_handler = _configure_logging(self._stream, options.verbose)

    def cleanup(self):
        """Restore logging configuration to its initial settings."""
        if self._logging_handler:
            _restore_logging(self._logging_handler)
            self._logging_handler = None

    def __del__(self):
        self.cleanup()

    # These two routines just hide the implementation of the switches.
    def disabled(self, option):
        return not option in self.switches

    def enabled(self, option):
        return option in self.switches

    def help_printing(self):
        self._write(HELP_PRINTING)

    def print_actual(self, msg):
        if self.disabled("actual"):
            return
        self._buildbot_stream.write("%s\n" % msg)

    def print_config(self, msg):
        self.write(msg, "config")

    def print_expected(self, msg):
        self.write(msg, "expected")

    def print_timing(self, msg):
        self.write(msg, "timing")

    def print_one_line_summary(self, total, expected, unexpected):
        """Print a one-line summary of the test run to stdout.

        Args:
          total: total number of tests run
          expected: number of expected results
          unexpected: number of unexpected results
        """
        if self.disabled("one-line-summary"):
            return

        incomplete = total - expected - unexpected
        if incomplete:
            self._write("")
            incomplete_str = " (%d didn't run)" % incomplete
            expected_str = str(expected)
        else:
            incomplete_str = ""
            expected_str = "All %d" % expected
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


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