From 89807a5277be5733c7a8308867103bd75a1ece23 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Sat, 26 Feb 2011 16:06:02 +0000 Subject: Issue #11330: Updated tests for correct asctime handling. --- Lib/logging/__init__.py | 2 +- Lib/test/test_logging.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index da12a0e..d9ac7d9 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -383,7 +383,7 @@ class StrFormatStyle(PercentStyle): class StringTemplateStyle(PercentStyle): default_format = '${message}' asctime_format = '${asctime}' - asctime_search = '${asctime' + asctime_search = '${asctime}' def __init__(self, fmt): self._fmt = fmt or self.default_format diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 9492b80..b29d400 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -1907,6 +1907,8 @@ class FormatterTest(unittest.TestCase): self.assertFalse(f.usesTime()) f = logging.Formatter('%(asctime)s') self.assertTrue(f.usesTime()) + f = logging.Formatter('%(asctime)-15s') + self.assertTrue(f.usesTime()) f = logging.Formatter('asctime') self.assertFalse(f.usesTime()) @@ -1920,6 +1922,10 @@ class FormatterTest(unittest.TestCase): self.assertFalse(f.usesTime()) f = logging.Formatter('{asctime}', style='{') self.assertTrue(f.usesTime()) + f = logging.Formatter('{asctime!s:15}', style='{') + self.assertTrue(f.usesTime()) + f = logging.Formatter('{asctime:15}', style='{') + self.assertTrue(f.usesTime()) f = logging.Formatter('asctime', style='{') self.assertFalse(f.usesTime()) @@ -1935,6 +1941,8 @@ class FormatterTest(unittest.TestCase): self.assertFalse(f.usesTime()) f = logging.Formatter('${asctime}', style='$') self.assertTrue(f.usesTime()) + f = logging.Formatter('${asctime', style='$') + self.assertFalse(f.usesTime()) f = logging.Formatter('$asctime', style='$') self.assertTrue(f.usesTime()) f = logging.Formatter('asctime', style='$') @@ -2097,7 +2105,7 @@ def test_main(): LogRecordFactoryTest, ChildLoggerTest, QueueHandlerTest, RotatingFileHandlerTest, LastResortTest, - #TimedRotatingFileHandlerTest + TimedRotatingFileHandlerTest ) if __name__ == "__main__": -- cgit v0.12