test_dates.py 文件源码

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

项目:ShelbySearch 作者: Agentscreech 项目源码 文件源码
def test_redshift_day(self):
        # Redshift is reported returning 1 day interval as microsec (bug #558)
        cur = self.conn.cursor()
        psycopg2.extensions.register_type(
            psycopg2.extensions.new_type(
                psycopg2.STRING.values, 'WAT', psycopg2.extensions.INTERVAL),
            cur)

        from datetime import timedelta
        for s, v in [
            ('0', timedelta(0)),
            ('1', timedelta(microseconds=1)),
            ('-1', timedelta(microseconds=-1)),
            ('1000000', timedelta(seconds=1)),
            ('86400000000', timedelta(days=1)),
            ('-86400000000', timedelta(days=-1)),
        ]:
            cur.execute("select %s::text", (s,))
            r = cur.fetchone()[0]
            self.assertEqual(r, v, "%s -> %s != %s" % (s, r, v))


# Only run the datetime tests if psycopg was compiled with support.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号