--- test_urllib2.py 2007-08-06 01:52:19.000000000 +0530 +++ test_urllib2-mdf.py 2007-08-06 02:11:31.650501080 +0530 @@ -868,6 +868,23 @@ except urllib2.HTTPError: self.assertEqual(count, urllib2.HTTPRedirectHandler.max_redirections) + # test cached redirection implemented for 301 redirection + def cached_redirect(h, req, url=to_url): + h.http_error_301(req, MockFile(), 301, "Blah", + MockHeaders({"location":url})) + req = Request(from_url, origin_req_host="example.com") + count = 0 + try: + while 1: + cached_redirect(h, req, "http://example.com/") + count = count + 1 + if count > 1: + # Check for presence of a cached dictionary. + # Content not checked as tests returns None. + # Independent redirection tests for 301 handled,however. + self.assert_(h.cache) + except urllib2.HTTPError: + self.assertEqual(count, urllib2.HTTPRedirectHandler.max_repeats) def test_cookie_redirect(self): # cookies shouldn't leak into redirected requests