Exemplo n.º 1
0
 def test_format_matches(self):
     """Test format includes expected output."""
     base_str = 'blue'
     blue_str = colors.ColorStr(base_str, colors.COLOR_MAP['b'])
     expected = 'INFO: this is {0}\n'.format(blue_str)
     self.log.info('this is #b<{0}>'.format(base_str))
     self.assertEqual(self.stream.getvalue(), expected)
Exemplo n.º 2
0
 def format(self, record):
     """Format the message."""
     message = _cast_message(record.msg)
     for val in COLOR_EXP.findall(message):
         message = message.replace(
             val, colors.ColorStr(val[3:-1], colors.COLOR_MAP[val[1]]))
     record.msg = message
     return logging.Formatter.format(self, record)
Exemplo n.º 3
0
 def test_make_str_white_unsupported(self):
     """Verify no color sequences on white"""
     self.assertEqual(
         colors.ColorStr('colored', colors.COLOR_MAP['w'], force_seq=False),
         'colored')
Exemplo n.º 4
0
 def test_make_str_magenta(self):
     """Verify can color strings magenta"""
     self.assertEqual(
         colors.ColorStr('colored', colors.COLOR_MAP['m'], force_seq=True),
         '\033[95mcolored\033[0m')
Exemplo n.º 5
0
 def test_make_str_white(self):
     """Verify can color strings white"""
     self.assertEqual(
         colors.ColorStr('colored', colors.COLOR_MAP['w'], force_seq=True),
         '\033[97mcolored\033[0m')
Exemplo n.º 6
0
 def test_make_str_cyan(self):
     """Verify can color strings cyan"""
     self.assertEqual(
         colors.ColorStr('colored', colors.COLOR_MAP['c'], force_seq=True),
         '\033[96mcolored\033[0m')
Exemplo n.º 7
0
 def test_make_str_red(self):
     """Verify can color strings red"""
     self.assertEqual(
         colors.ColorStr('colored', colors.COLOR_MAP['r'], force_seq=True),
         '\033[91mcolored\033[0m')
Exemplo n.º 8
0
 def test_make_str_yellow(self):
     """Verify can color strings yellow"""
     self.assertEqual(
         colors.ColorStr('colored', colors.COLOR_MAP['y'], force_seq=True),
         "\033[93mcolored\033[0m")