Example #1
0
    def testFormat(self):
        msg = '<red>WARNING:</red> hello world'
        expected = '\033[0;31mWARNING:\033[m hello world'
        actual = colors.format(msg)
        self.assertEqual(expected, actual)

        msg = '<red>WARNING:</red> %s'
        expected = '\033[0;31mWARNING:\033[m hello'
        actual = colors.format(msg, 'hello')
        self.assertEqual(expected, actual)

        msg = '<red>WARNING:<blue></red> foo</blue>'
        expected = '\033[0;31mWARNING:<blue>\033[m foo</blue>'
        actual = colors.format(msg)
        self.assertEqual(expected, actual)

        msg = '<red>WARNING:</red> foo <blue>bar</blue>'
        expected = '\033[0;31mWARNING:\033[m foo \033[0;34mbar\033[m'
        actual = colors.format(msg)
        self.assertEqual(expected, actual)

        msg = '<red>WARNING:</red> foo <yellow>bar</yellow>'
        expected = '\033[0;31mWARNING:\033[m foo \033[1;33mbar\033[m'
        actual = colors.format(msg)
        self.assertEqual(expected, actual)

        msg = '<red>WARNING:</red> foo <red>bar</red>'
        expected = '\033[0;31mWARNING:\033[m foo \033[0;31mbar\033[m'
        actual = colors.format(msg)
        self.assertEqual(expected, actual)
Example #2
0
  def testFormat(self):
    msg = '<red>WARNING:</red> hello world'
    expected = '\033[0;31mWARNING:\033[m hello world'
    actual = colors.format(msg)
    self.assertEqual(expected, actual)

    msg = '<red>WARNING:</red> %s'
    expected = '\033[0;31mWARNING:\033[m hello'
    actual = colors.format(msg, 'hello')
    self.assertEqual(expected, actual)

    msg = '<red>WARNING:<blue></red> foo</blue>'
    expected = '\033[0;31mWARNING:<blue>\033[m foo</blue>'
    actual = colors.format(msg)
    self.assertEqual(expected, actual)

    msg = '<red>WARNING:</red> foo <blue>bar</blue>'
    expected = '\033[0;31mWARNING:\033[m foo \033[0;34mbar\033[m'
    actual = colors.format(msg)
    self.assertEqual(expected, actual)

    msg = '<red>WARNING:</red> foo <yellow>bar</yellow>'
    expected = '\033[0;31mWARNING:\033[m foo \033[1;33mbar\033[m'
    actual = colors.format(msg)
    self.assertEqual(expected, actual)

    msg = '<red>WARNING:</red> foo <red>bar</red>'
    expected = '\033[0;31mWARNING:\033[m foo \033[0;31mbar\033[m'
    actual = colors.format(msg)
    self.assertEqual(expected, actual)
Example #3
0
 def print_error(self, msg):
   if self.suppress_errors:
     return
   msg = colors.format('<red>ERROR</red>: %s', msg)
   self._print(msg, to_stderr=True)
Example #4
0
 def print_warning(self, msg):
   if self.suppress_warnings:
     return
   msg = colors.format('<red>WARNING</red>: %s', msg)
   self._print(msg, to_stderr=True)
Example #5
0
 def print_error(self, msg):
     if self.suppress_errors:
         return
     msg = colors.format('<red>ERROR</red>: %s', msg)
     self._print(msg, to_stderr=True)
Example #6
0
 def print_warning(self, msg):
     if self.suppress_warnings:
         return
     msg = colors.format('<red>WARNING</red>: %s', msg)
     self._print(msg, to_stderr=True)