def test_infer_tz(self):
eastern = self.tz('US/Eastern')
utc = pytz.utc
_start = datetime(2001, 1, 1)
_end = datetime(2009, 1, 1)
start = self.localize(eastern, _start)
end = self.localize(eastern, _end)
assert (tools._infer_tzinfo(start, end) is self.localize(
eastern, _start).tzinfo)
assert (tools._infer_tzinfo(start, None) is self.localize(
eastern, _start).tzinfo)
assert (tools._infer_tzinfo(None, end) is self.localize(eastern,
_end).tzinfo)
start = utc.localize(_start)
end = utc.localize(_end)
assert (tools._infer_tzinfo(start, end) is utc)
end = self.localize(eastern, _end)
self.assertRaises(Exception, tools._infer_tzinfo, start, end)
self.assertRaises(Exception, tools._infer_tzinfo, end, start)
test_timezones.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录