def test_log_format_relative_created_float(self): fmt = '%(relativeCreated)+.3f' self.assertEqual(handlers.log_format(fmt), fmt)
def test_log_format_levelno_integer(self): fmt = '%(levelno)2d' self.assertEqual(handlers.log_format(fmt), fmt)
def test_log_format_msecs_float(self): fmt = '%(msecs)03.0f' self.assertEqual(handlers.log_format(fmt), fmt)
def test_log_format_func_name(self): fmt = '%(funcName)s' self.assertEqual(handlers.log_format(fmt), fmt)
def test_log_format_ok(self): fmt = handlers.log_format(r'\n\t\b\f\r') self.assertEqual(fmt, '\n\t\b\f\r')
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')
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)')
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')