Python httplib2 模块,RETRIES 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用httplib2.RETRIES

项目:httplib2    作者:httplib2    | 项目源码 | 文件源码
def testBadStatusLineRetry(self):
        old_retries = httplib2.RETRIES
        httplib2.RETRIES = 1
        self.http.force_exception_to_status_code = False
        try:
            response, content = self.http.request("http://bitworking.org",
                connection_type=_MyHTTPBadStatusConnection)
        except httplib.BadStatusLine:
            self.assertEqual(2, _MyHTTPBadStatusConnection.num_calls)
        httplib2.RETRIES = old_retries
项目:httplib2    作者:httplib2    | 项目源码 | 文件源码
def testBadStatusLineRetry(self):
        old_retries = httplib2.RETRIES
        httplib2.RETRIES = 1
        self.http.force_exception_to_status_code = False
        try:
            response, content = self.http.request("http://bitworking.org",
                connection_type=_MyHTTPBadStatusConnection)
        except http.client.BadStatusLine:
            self.assertEqual(2, _MyHTTPBadStatusConnection.num_calls)
        httplib2.RETRIES = old_retries
项目:httplib2shim    作者:GoogleCloudPlatform    | 项目源码 | 文件源码
def testIPv6SSL(self):
        try:
            self.http.request("https://[::1]/")
        except socket.gaierror:
            self.fail("should get the address family right for IPv6")
        except socket.error:
            pass

    # NOTE: Disabled because it's not applicable to the shim
    # def testConnectionType(self):
    #     self.http.force_exception_to_status_code = False
    #     response, content = self.http.request(
    #        "http://bitworking.org", connection_type=_MyHTTPConnection)
    #     self.assertEqual(
    #        response['content-location'], "http://bitworking.org")
    #     self.assertEqual(content, b"the body")

    # NOTE: Disabled because I don't yet have a good way to test this.
    # def testBadStatusLineRetry(self):
    #     old_retries = httplib2.RETRIES
    #     httplib2.RETRIES = 1
    #     self.http.force_exception_to_status_code = False
    #     try:
    #         response, content = self.http.request("http://bitworking.org",
    #             connection_type=_MyHTTPBadStatusConnection)
    #     except http.client.BadStatusLine:
    #         self.assertEqual(2, _MyHTTPBadStatusConnection.num_calls)
    #     httplib2.RETRIES = old_retries