diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-10-26 13:16:11 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-10-26 13:16:11 (GMT) |
commit | 6a65c5df869f2526711ff00c07ca28e2dc394372 (patch) | |
tree | c02ab0cdb45c1995b2b64d622635f639666a47d4 /Lib/test | |
parent | ba488d150492aa6ded31da7b055cd85a152dd611 (diff) | |
download | cpython-6a65c5df869f2526711ff00c07ca28e2dc394372.zip cpython-6a65c5df869f2526711ff00c07ca28e2dc394372.tar.gz cpython-6a65c5df869f2526711ff00c07ca28e2dc394372.tar.bz2 |
logging: Improved Formatter implementation.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_logging.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 9aa6af3..11e18d8 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -1891,6 +1891,11 @@ class FormatterTest(unittest.TestCase): self.assertEqual(f.format(r), '${Message with 2 placeholders}') f = logging.Formatter('%(random)s') self.assertRaises(KeyError, f.format, r) + self.assertFalse(f.usesTime()) + f = logging.Formatter('%(asctime)s') + self.assertTrue(f.usesTime()) + f = logging.Formatter('asctime') + self.assertFalse(f.usesTime()) def test_braces(self): "Test {}-formatting" @@ -1899,6 +1904,11 @@ class FormatterTest(unittest.TestCase): self.assertEqual(f.format(r), '$%Message with 2 placeholders%$') f = logging.Formatter('{random}', style='{') self.assertRaises(KeyError, f.format, r) + self.assertFalse(f.usesTime()) + f = logging.Formatter('{asctime}', style='{') + self.assertTrue(f.usesTime()) + f = logging.Formatter('asctime', style='{') + self.assertFalse(f.usesTime()) def test_dollars(self): "Test $-formatting" @@ -1909,6 +1919,13 @@ class FormatterTest(unittest.TestCase): self.assertEqual(f.format(r), '$%Message with 2 placeholders%$') f = logging.Formatter('${random}', style='$') self.assertRaises(KeyError, f.format, r) + self.assertFalse(f.usesTime()) + f = logging.Formatter('${asctime}', style='$') + self.assertTrue(f.usesTime()) + f = logging.Formatter('$asctime', style='$') + self.assertTrue(f.usesTime()) + f = logging.Formatter('asctime', style='$') + self.assertFalse(f.usesTime()) class BaseFileTest(BaseTest): "Base class for handler tests that write log files" |