test_copy.py 文件源码

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

项目:userbase-sns-lambda 作者: fartashh 项目源码 文件源码
def test_copy_from_propagate_error(self):
        class BrokenRead(_base):
            def read(self, size):
                return 1/0

            def readline(self):
                return 1/0

        curs = self.conn.cursor()
        # It seems we cannot do this, but now at least we propagate the error
        # self.assertRaises(ZeroDivisionError,
        #     curs.copy_from, BrokenRead(), "tcopy")
        try:
            curs.copy_from(BrokenRead(), "tcopy")
        except Exception, e:
            self.assert_('ZeroDivisionError' in str(e))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号