test_sitkaAPI.py 文件源码

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

项目:CHaMP_Metrics 作者: SouthForkResearch 项目源码 文件源码
def test_APIGetWeirdError(self):
        """
        Make sure we handle weird exceptions properly
        We should see a bunch of retries
        :return:
        """
        import requests

        # MonkeyPatching!!!
        def fakefunc(a, headers=False):
            raise Exception("I AM FAKE")
        requests.__dict__['get'] = fakefunc

        with self.assertRaises(NetworkException) as e:
            result = APIGet('IAmaTeapot')

        # Make sure we've freaked out appropriately
        self.assertTrue(e.exception.message.index("Connection Exception:") == 0)
        # Make sure we've done the requisite number of retries
        self.assertEqual(int(e.exception.message[-1]), RETRIES_ALLOWED)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号