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

Method test_fromutc

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

Source from the content-addressed store, hash-verified

355 with self.assertRaises(TypeError): self.EST.tzname(5)
356
357 def test_fromutc(self):
358 with self.assertRaises(ValueError):
359 timezone.utc.fromutc(self.DT)
360 with self.assertRaises(TypeError):
361 timezone.utc.fromutc('not datetime')
362 for tz in [self.EST, self.ACDT, Eastern]:
363 utctime = self.DT.replace(tzinfo=tz)
364 local = tz.fromutc(utctime)
365 self.assertEqual(local - utctime, tz.utcoffset(local))
366 self.assertEqual(local,
367 self.DT.replace(tzinfo=timezone.utc))
368
369 def test_comparison(self):
370 self.assertNotEqual(timezone(ZERO), timezone(HOUR))

Callers

nothing calls this directly

Calls 5

assertRaisesMethod · 0.45
fromutcMethod · 0.45
replaceMethod · 0.45
assertEqualMethod · 0.45
utcoffsetMethod · 0.45

Tested by

no test coverage detected