def test_redirect_bad_uri(self):
# bad URIs should be cleaned up before redirection
from mechanize._response import test_html_response
from_url = "http://example.com/a.html"
bad_to_url = "http://example.com/b. |html"
good_to_url = "http://example.com/b.%20%7Chtml"
h = HTTPRedirectHandler()
o = h.parent = MockOpener()
req = Request(from_url)
h.http_error_302(
req,
test_html_response(),
302,
"Blah",
http_message({
"location": bad_to_url
}), )
self.assertEqual(o.req.get_full_url(), good_to_url)
评论列表
文章目录