httplib2test.py 文件源码

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

项目:httplib2 作者: httplib2 项目源码 文件源码
def testGetUnknownServer(self):
        self.http.force_exception_to_status_code = False
        try:
            self.http.request("http://fred.bitworking.org/")
            self.fail("An httplib2.ServerNotFoundError Exception must be thrown on an unresolvable server.")
        except httplib2.ServerNotFoundError:
            pass

        # Now test with exceptions turned off
        self.http.force_exception_to_status_code = True

        (response, content) = self.http.request("http://fred.bitworking.org/")
        self.assertEqual(response['content-type'], 'text/plain')
        self.assertTrue(content.startswith("Unable to find"))
        self.assertEqual(response.status, 400)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号