diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py index 0a34f9a1bc8..eb542ba96b0 100644 --- a/aiohttp/helpers.py +++ b/aiohttp/helpers.py @@ -254,7 +254,7 @@ def atoms(message, environ, response, transport, request_time): 'f': headers.get(hdrs.REFERER, '-'), 'a': headers.get(hdrs.USER_AGENT, '-'), 'T': str(int(request_time)), - 'D': str(request_time).split('.', 1)[-1][:5], + 'D': str(request_time).split('.', 1)[-1][:6], 'p': "<%s>" % os.getpid() } diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 875e99fa28f..dc9e94be4a6 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -116,6 +116,17 @@ def prop(self): a.prop = 123 +class TestAtoms(unittest.TestCase): + + def test_get_seconds_and_milliseconds(self): + response = dict(status=200, output_length=1) + request_time = 321.012345678901234 + + atoms = helpers.atoms(None, None, response, None, request_time) + self.assertEqual(atoms['T'], '321') + self.assertEqual(atoms['D'], '012345') + + class TestSafeAtoms(unittest.TestCase): def test_get_non_existing(self):