diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2009-07-19 02:44:19 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2009-07-19 02:44:19 (GMT) |
commit | fb8cc2f5a4bb55cabc94999360a324a73a0022cd (patch) | |
tree | 1068a6973bb9d8eb01b2a0fdf8ba1570df3f6a9a /Lib/test/test_urllib2.py | |
parent | 046f7233f6b5eb0c44ce9ec8eb9ff0294a8922b9 (diff) | |
download | cpython-fb8cc2f5a4bb55cabc94999360a324a73a0022cd.zip cpython-fb8cc2f5a4bb55cabc94999360a324a73a0022cd.tar.gz cpython-fb8cc2f5a4bb55cabc94999360a324a73a0022cd.tar.bz2 |
Fix for issue5102, timeout value propages between redirects, proxy, digest and
auth handlers. Fixed tests to reflect the same.
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r-- | Lib/test/test_urllib2.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index f996c71..7efa1d8 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -222,8 +222,8 @@ def test_password_manager_default_port(self): class MockOpener: addheaders = [] - def open(self, req, data=None): - self.req, self.data = req, data + def open(self, req, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): + self.req, self.data, self.timeout = req, data, timeout def error(self, proto, *args): self.proto, self.args = proto, args @@ -854,6 +854,7 @@ class HandlerTests(unittest.TestCase): for data in None, "blah\nblah\n": method = getattr(h, "http_error_%s" % code) req = Request(from_url, data) + req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT req.add_header("Nonsense", "viking=withhold") if data is not None: req.add_header("Content-Length", str(len(data))) @@ -883,6 +884,7 @@ class HandlerTests(unittest.TestCase): # loop detection req = Request(from_url) + req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT def redirect(h, req, url=to_url): h.http_error_302(req, MockFile(), 302, "Blah", MockHeaders({"location": url})) @@ -892,6 +894,7 @@ class HandlerTests(unittest.TestCase): # detect infinite loop redirect of a URL to itself req = Request(from_url, origin_req_host="example.com") count = 0 + req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT try: while 1: redirect(h, req, "http://example.com/") @@ -903,6 +906,7 @@ class HandlerTests(unittest.TestCase): # detect endless non-repeating chain of redirects req = Request(from_url, origin_req_host="example.com") count = 0 + req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT try: while 1: redirect(h, req, "http://example.com/%d" % count) |