diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-17 18:02:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-17 17:02:47 +0100 |
commit | 06a35542aad15666cace307d841a95e33f3cbee6 (patch) | |
tree | 1181345efbb9ba1fcbdac907ff8e6598ce10243c /Lib/test | |
parent | 1ae035b7e847064d09df01ca62b8a761e9b5aae3 (diff) | |
download | cpython-git-06a35542aad15666cace307d841a95e33f3cbee6.tar.gz |
bpo-40300: Allow empty logging.Formatter.default_msec_format. (GH-19551)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_logging.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 2ad3c5c208..99e74ebff6 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -3941,6 +3941,19 @@ class FormatterTest(unittest.TestCase): f.format(r) self.assertEqual(r.asctime, '1993-04-21 08:03:00,123') + def test_default_msec_format_none(self): + class NoMsecFormatter(logging.Formatter): + default_msec_format = None + default_time_format = '%d/%m/%Y %H:%M:%S' + + r = self.get_record() + dt = datetime.datetime(1993, 4, 21, 8, 3, 0, 123, utc) + r.created = time.mktime(dt.astimezone(None).timetuple()) + f = NoMsecFormatter() + f.converter = time.gmtime + self.assertEqual(f.formatTime(r), '21/04/1993 08:03:00') + + class TestBufferingFormatter(logging.BufferingFormatter): def formatHeader(self, records): return '[(%d)' % len(records) |