示例#1
0
 def test_log_format_relative_created_float(self):
     fmt = '%(relativeCreated)+.3f'
     self.assertEqual(handlers.log_format(fmt), fmt)
示例#2
0
 def test_log_format_levelno_integer(self):
     fmt = '%(levelno)2d'
     self.assertEqual(handlers.log_format(fmt), fmt)
示例#3
0
 def test_log_format_msecs_float(self):
     fmt = '%(msecs)03.0f'
     self.assertEqual(handlers.log_format(fmt), fmt)
示例#4
0
 def test_log_format_func_name(self):
     fmt = '%(funcName)s'
     self.assertEqual(handlers.log_format(fmt), fmt)
示例#5
0
 def test_log_format_ok(self):
     fmt = handlers.log_format(r'\n\t\b\f\r')
     self.assertEqual(fmt, '\n\t\b\f\r')
示例#6
0
 def test_log_format_unknown_key(self):
     with self.assertRaises(ValueError) as cm:
         handlers.log_format('%(no-such-key)s')
     self.assertEqual(str(cm.exception),
                      'Invalid log format string %(no-such-key)s')
示例#7
0
 def test_log_format_bad_syntax_2(self):
     with self.assertRaises(ValueError) as cm:
         # Missing trailing 's':
         handlers.log_format('%(levelname)')
     self.assertEqual(str(cm.exception),
                      'Invalid log format string %(levelname)')
示例#8
0
 def test_log_format_bad_syntax_1(self):
     with self.assertRaises(ValueError) as cm:
         # Really, disallowed character following '%':
         handlers.log_format('%{no-such-key}s')
     self.assertEqual(str(cm.exception),
                      'Invalid log format string %{no-such-key}s')