MCPcopy Index your code
hub / github.com/python/cpython / test_time

Method test_time

Lib/test/test_logging.py:4826–4838  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4824 self.assertRaises(ValueError, logging.Formatter, None, None, 'x')
4825
4826 def test_time(self):
4827 r = self.get_record()
4828 dt = datetime.datetime(1993, 4, 21, 8, 3, 0, 0, utc)
4829 # We use None to indicate we want the local timezone
4830 # We're essentially converting a UTC time to local time
4831 r.created = time.mktime(dt.astimezone(None).timetuple())
4832 r.msecs = 123
4833 f = logging.Formatter('%(asctime)s %(message)s')
4834 f.converter = time.gmtime
4835 self.assertEqual(f.formatTime(r), '1993-04-21 08:03:00,123')
4836 self.assertEqual(f.formatTime(r, '%Y:%d'), '1993:21')
4837 f.format(r)
4838 self.assertEqual(r.asctime, '1993-04-21 08:03:00,123')
4839
4840 def test_default_msec_format_none(self):
4841 class NoMsecFormatter(logging.Formatter):

Callers

nothing calls this directly

Calls 7

get_recordMethod · 0.95
formatTimeMethod · 0.95
formatMethod · 0.95
datetimeMethod · 0.80
astimezoneMethod · 0.80
timetupleMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected