mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Timeouts are normal errors now.
-- BREAK ALL TEH TESTS!
This commit is contained in:
+5
-5
@@ -296,15 +296,15 @@ class Request(object):
|
||||
if self.cookiejar is not None:
|
||||
self.cookiejar.extract_cookies(resp, req)
|
||||
|
||||
except urllib2.HTTPError, why:
|
||||
except (urllib2.HTTPError, urllib2.URLError), why:
|
||||
if hasattr(why, 'reason'):
|
||||
if isinstance(why.reason, socket.timeout):
|
||||
why = Timeout(why)
|
||||
|
||||
self._build_response(why)
|
||||
if not self.redirect:
|
||||
self.response.error = why
|
||||
|
||||
# TODO: Support urllib connection refused errors
|
||||
|
||||
except urllib2.URLError, error:
|
||||
raise Timeout if isinstance(error.reason, socket.timeout) else error
|
||||
else:
|
||||
self._build_response(resp)
|
||||
self.response.ok = True
|
||||
|
||||
+6
-1
@@ -246,8 +246,13 @@ class RequestsTestSuite(unittest.TestCase):
|
||||
|
||||
|
||||
def test_settings(self):
|
||||
|
||||
def test():
|
||||
r = requests.get(httpbin(''))
|
||||
r.raise_for_status()
|
||||
|
||||
with requests.settings(timeout=0.0000001):
|
||||
self.assertRaises(requests.Timeout, requests.get, httpbin(''))
|
||||
self.assertRaises(requests.Timeout, test)
|
||||
|
||||
with requests.settings(timeout=100):
|
||||
requests.get(httpbin(''))
|
||||
|
||||
Reference in New Issue
Block a user