Exemple #1
0
 def print_test_list(tag, test_list):
     for qualified_name, flag in sorted(test_list):
         line_color = _REPORT_COLOR_FOR_SUITE_EXPECTATION[
             scoreboard.Scoreboard.map_expectation_flag_to_result(flag)]
         color.write_ansi_escape(
             sys.stdout, line_color,
             '[%-4s %-*s] %s\n' % (tag, flag_width, flag, qualified_name))
Exemple #2
0
 def print_test_list(tag, test_list):
   for qualified_name, flag in sorted(test_list):
     line_color = _REPORT_COLOR_FOR_SUITE_EXPECTATION[
         scoreboard.Scoreboard.map_expectation_flag_to_result(flag)]
     color.write_ansi_escape(
         sys.stdout, line_color,
         '[%-4s %-*s] %s\n' % (tag, flag_width, flag, qualified_name))
Exemple #3
0
  def test_write_ansi_escape(self):
    # If stream is a tty, the text should be formatted with escape sequence.
    stream = MockStream()
    stream._isatty = True
    color.write_ansi_escape(stream, color.RED, TestColorUtil.TEXT)
    self.assertEqual('\x1b[31;1m99 bottles of beer\x1b[m', stream.getvalue())
    stream.close()

    # If stream is not a tty, the text should be output to the stream as is.
    stream = MockStream()
    color.write_ansi_escape(stream, color.RED, TestColorUtil.TEXT)
    self.assertEqual(TestColorUtil.TEXT, stream.getvalue())
    stream.close()

    # It is legal to pass None for |escape|.
    stream = MockStream()
    color.write_ansi_escape(stream, None, TestColorUtil.TEXT)
    self.assertEqual(TestColorUtil.TEXT, stream.getvalue())
    stream.close()
Exemple #4
0
    def test_write_ansi_escape(self):
        # If stream is a tty, the text should be formatted with escape sequence.
        stream = MockStream()
        stream._isatty = True
        color.write_ansi_escape(stream, color.RED, TestColorUtil.TEXT)
        self.assertEqual('\x1b[31;1m99 bottles of beer\x1b[m',
                         stream.getvalue())
        stream.close()

        # If stream is not a tty, the text should be output to the stream as is.
        stream = MockStream()
        color.write_ansi_escape(stream, color.RED, TestColorUtil.TEXT)
        self.assertEqual(TestColorUtil.TEXT, stream.getvalue())
        stream.close()

        # It is legal to pass None for |escape|.
        stream = MockStream()
        color.write_ansi_escape(stream, None, TestColorUtil.TEXT)
        self.assertEqual(TestColorUtil.TEXT, stream.getvalue())
        stream.close()
Exemple #5
0
 def puts(self, text, use_color=None):
   color.write_ansi_escape(sys.stdout, use_color, text)