diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2009-07-19 02:43:43 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2009-07-19 02:43:43 (GMT) |
commit | 5fee460bfabc248ca8c14fc2403fdfabf5051dad (patch) | |
tree | 8090bef8304ca359e9c0071b6cc17d518997c7b0 /Lib/test/test_urllib2.py | |
parent | 5215875a95c0a08a688e897f4675be038f83a117 (diff) | |
download | cpython-5fee460bfabc248ca8c14fc2403fdfabf5051dad.zip cpython-5fee460bfabc248ca8c14fc2403fdfabf5051dad.tar.gz cpython-5fee460bfabc248ca8c14fc2403fdfabf5051dad.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 1dcd616..d4288f8 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -224,8 +224,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 @@ -850,6 +850,7 @@ class HandlerTests(unittest.TestCase): method = getattr(h, "http_error_%s" % code) req = Request(from_url, data) req.add_header("Nonsense", "viking=withhold") + req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT if data is not None: req.add_header("Content-Length", str(len(data))) req.add_unredirected_header("Spam", "spam") @@ -878,6 +879,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})) @@ -887,6 +889,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/") @@ -898,6 +901,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) |