test_error_recovery.py 文件源码

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

项目:time2go 作者: twitchyliquid64 项目源码 文件源码
def testClosedConnection(self):
        warnings.simplefilter("ignore")
        my_db = pg8000.connect(**db_connect)
        cursor = my_db.cursor()
        my_db.close()
        try:
            cursor.execute("VALUES ('hw1'::text)")
            self.fail("Should have raised an exception")
        except:
            e = exc_info()[1]
            self.assertTrue(isinstance(e, self.db.InterfaceError))
            self.assertEqual(str(e), 'connection is closed')

        warnings.resetwarnings()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号