Timeouts are normal errors now.

--
BREAK ALL TEH TESTS!
This commit is contained in:
Kenneth Reitz
2011-06-21 22:40:27 -04:00
parent 20aed5488b
commit 162b751f6d
2 changed files with 11 additions and 6 deletions
+5 -5
View File
@@ -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
View File
@@ -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(''))