test_module.py 文件源码

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

项目:psycopg2-for-aws-lambda 作者: iwitaly 项目源码 文件源码
def test_diagnostics_life(self):
        import gc
        from weakref import ref

        def tmp():
            cur = self.conn.cursor()
            try:
                cur.execute("select * from nonexist")
            except psycopg2.Error, exc:
                return cur, exc

        cur, e = tmp()
        diag = e.diag
        w = ref(cur)

        del e, cur
        gc.collect()
        assert(w() is not None)

        self.assertEqual(diag.sqlstate, '42P01')

        del diag
        gc.collect()
        gc.collect()
        assert(w() is None)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号