Ejemplo n.º 1
0
 def test_braces(self):
     "Test {}-formatting"
     r = self.get_record()
     f = logutils.Formatter('$%{message}%$', style='{')
     self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
     f = logutils.Formatter('{random}', style='{')
     self.assertRaises(KeyError, f.format, r)
     self.assertFalse(f.usesTime())
     f = logutils.Formatter('{asctime}', style='{')
     self.assertTrue(f.usesTime())
     f = logutils.Formatter('asctime', style='{')
     self.assertFalse(f.usesTime())
Ejemplo n.º 2
0
 def test_percent(self):
     "Test %-formatting"
     r = self.get_record()
     f = logutils.Formatter('${%(message)s}')
     self.assertEqual(f.format(r), '${Message with 2 placeholders}')
     f = logutils.Formatter('%(random)s')
     self.assertRaises(KeyError, f.format, r)
     self.assertFalse(f.usesTime())
     f = logutils.Formatter('%(asctime)s')
     self.assertTrue(f.usesTime())
     f = logutils.Formatter('asctime')
     self.assertFalse(f.usesTime())
Ejemplo n.º 3
0
 def test_dollars(self):
     "Test $-formatting"
     r = self.get_record()
     f = logutils.Formatter('$message', style='$')
     self.assertEqual(f.format(r), 'Message with 2 placeholders')
     f = logutils.Formatter('$$%${message}%$$', style='$')
     self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
     f = logutils.Formatter('${random}', style='$')
     self.assertRaises(KeyError, f.format, r)
     self.assertFalse(f.usesTime())
     f = logutils.Formatter('${asctime}', style='$')
     self.assertTrue(f.usesTime())
     f = logutils.Formatter('$asctime', style='$')
     self.assertTrue(f.usesTime())
     f = logutils.Formatter('asctime', style='$')
     self.assertFalse(f.usesTime())