testutils.py 文件源码

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

项目:userbase-sns-lambda 作者: fartashh 项目源码 文件源码
def skip_if_no_uuid(f):
    """Decorator to skip a test if uuid is not supported by Py/PG."""
    @wraps(f)
    def skip_if_no_uuid_(self):
        try:
            import uuid
        except ImportError:
            return self.skipTest("uuid not available in this Python version")

        try:
            cur = self.conn.cursor()
            cur.execute("select typname from pg_type where typname = 'uuid'")
            has = cur.fetchone()
        finally:
            self.conn.rollback()

        if has:
            return f(self)
        else:
            return self.skipTest("uuid type not available on the server")

    return skip_if_no_uuid_
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号