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)
评论列表
文章目录