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
python类RETRIES的实例源码
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
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