[3.11] gh-89047: Fix msecs computation so you never end up with 1000 msecs. (GH-96340) (GH-96341)

This commit is contained in:
Miss Islington (bot) 2022-08-27 07:09:54 -07:00 committed by GitHub
parent 698df306a9
commit 103f26f282
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -4088,6 +4088,14 @@ class FormatterTest(unittest.TestCase, AssertErrorMessage):
f.converter = time.gmtime
self.assertEqual(f.formatTime(r), '21/04/1993 08:03:00')
def test_issue_89047(self):
f = logging.Formatter(fmt='{asctime}.{msecs:03.0f} {message}', style='{', datefmt="%Y-%m-%d %H:%M:%S")
for i in range(2500):
time.sleep(0.0004)
r = logging.makeLogRecord({'msg': 'Message %d' % (i + 1)})
s = f.format(r)
self.assertNotIn('.1000', s)
class TestBufferingFormatter(logging.BufferingFormatter):
def formatHeader(self, records):