test_timezones.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号