MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_fromisoformat_timespecs

Method test_fromisoformat_timespecs

Lib/test/datetimetester.py:3378–3402  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3376 self.assertEqual(dt, dt_rt)
3377
3378 def test_fromisoformat_timespecs(self):
3379 datetime_bases = [
3380 (2009, 12, 4, 8, 17, 45, 123456),
3381 (2009, 12, 4, 8, 17, 45, 0)]
3382
3383 tzinfos = [None, timezone.utc,
3384 timezone(timedelta(hours=-5)),
3385 timezone(timedelta(hours=2)),
3386 timezone(timedelta(hours=6, minutes=27))]
3387
3388 timespecs = ['hours', 'minutes', 'seconds',
3389 'milliseconds', 'microseconds']
3390
3391 for ip, ts in enumerate(timespecs):
3392 for tzi in tzinfos:
3393 for dt_tuple in datetime_bases:
3394 if ts == 'milliseconds':
3395 new_microseconds = 1000 * (dt_tuple[6] // 1000)
3396 dt_tuple = dt_tuple[0:6] + (new_microseconds,)
3397
3398 dt = self.theclass(*(dt_tuple[0:(4 + ip)]), tzinfo=tzi)
3399 dtstr = dt.isoformat(timespec=ts)
3400 with self.subTest(dtstr=dtstr):
3401 dt_rt = self.theclass.fromisoformat(dtstr)
3402 self.assertEqual(dt, dt_rt)
3403
3404 def test_fromisoformat_datetime_examples(self):
3405 UTC = timezone.utc

Callers

nothing calls this directly

Calls 7

timezoneClass · 0.90
timedeltaClass · 0.90
enumerateFunction · 0.85
subTestMethod · 0.80
isoformatMethod · 0.45
fromisoformatMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected