def test_fromutc(self):
with self.assertRaises(ValueError):
timezone.utc.fromutc(self.DT)
with self.assertRaises(TypeError):
timezone.utc.fromutc('not datetime')
for tz in [self.EST, self.ACDT, Eastern]:
utctime = self.DT.replace(tzinfo=tz)
local = tz.fromutc(utctime)
self.assertEqual(local - utctime, tz.utcoffset(local))
self.assertEqual(local,
self.DT.replace(tzinfo=timezone.utc))
评论列表
文章目录