summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib2.py
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2011-04-12 23:22:29 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2011-04-12 23:22:29 (GMT)
commitb17abb1af9e36c728e4fc9e27a9fd9441d3f77a2 (patch)
tree7e424e947cbf556f5b39cc97dc2d22d66333155f /Lib/test/test_urllib2.py
parenta3e449da3757a87945d62d104cb53ff8a8646257 (diff)
parent26430419703f925a9b6206ec96780ae899b6dd06 (diff)
downloadcpython-b17abb1af9e36c728e4fc9e27a9fd9441d3f77a2.zip
cpython-b17abb1af9e36c728e4fc9e27a9fd9441d3f77a2.tar.gz
cpython-b17abb1af9e36c728e4fc9e27a9fd9441d3f77a2.tar.bz2
merge from 3.1
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r--Lib/test/test_urllib2.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 39447a8..e9fb2fc 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -1070,6 +1070,15 @@ class HandlerTests(unittest.TestCase):
o.open("http://www.example.com/")
self.assertFalse(hh.req.has_header("Cookie"))
+ def test_redirect_fragment(self):
+ redirected_url = 'http://www.example.com/index.html#OK\r\n\r\n'
+ hh = MockHTTPHandler(302, 'Location: ' + redirected_url)
+ hdeh = urllib.request.HTTPDefaultErrorHandler()
+ hrh = urllib.request.HTTPRedirectHandler()
+ o = build_test_opener(hh, hdeh, hrh)
+ fp = o.open('http://www.example.com')
+ self.assertEqual(fp.geturl(), redirected_url.strip())
+
def test_proxy(self):
o = OpenerDirector()
ph = urllib.request.ProxyHandler(dict(http="proxy.example.com:3128"))
@@ -1385,12 +1394,16 @@ class RequestTests(unittest.TestCase):
req = Request("<URL:http://www.python.org>")
self.assertEqual("www.python.org", req.get_host())
- def test_urlwith_fragment(self):
+ def test_url_fragment(self):
req = Request("http://www.python.org/?qs=query#fragment=true")
self.assertEqual("/?qs=query", req.get_selector())
req = Request("http://www.python.org/#fun=true")
self.assertEqual("/", req.get_selector())
+ # Issue 11703: geturl() omits fragment in the original URL.
+ url = 'http://docs.python.org/library/urllib2.html#OK'
+ req = Request(url)
+ self.assertEqual(req.get_full_url(), url)
def test_main(verbose=None):
from test import test_urllib2