summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-04-12 23:34:06 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-04-12 23:34:06 (GMT)
commitabdeeff3d1fa505fa1d49970cb7a70446f3e2b75 (patch)
tree23131ed5d3928e8056f1cc28c6818b3ac43dd73a /Lib/test
parentbd3e362089c9fab1028a1bf58b4e762851a32244 (diff)
parent26430419703f925a9b6206ec96780ae899b6dd06 (diff)
downloadcpython-abdeeff3d1fa505fa1d49970cb7a70446f3e2b75.zip
cpython-abdeeff3d1fa505fa1d49970cb7a70446f3e2b75.tar.gz
cpython-abdeeff3d1fa505fa1d49970cb7a70446f3e2b75.tar.bz2
merge heads
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_urllib.py10
-rw-r--r--Lib/test/test_urllib2.py15
-rw-r--r--Lib/test/test_urllib2net.py2
3 files changed, 25 insertions, 2 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 2b88521..462a2b0 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -171,6 +171,16 @@ class urlopen_HttpTests(unittest.TestCase):
finally:
self.unfakehttp()
+ def test_url_fragment(self):
+ # Issue #11703: geturl() omits fragments in the original URL.
+ url = 'http://docs.python.org/library/urllib.html#OK'
+ self.fakehttp(b'Hello!')
+ try:
+ fp = urllib.request.urlopen(url)
+ self.assertEqual(fp.geturl(), url)
+ finally:
+ self.unfakehttp()
+
def test_read_bogus(self):
# urlopen() should raise IOError for many error codes.
self.fakehttp(b'''HTTP/1.1 401 Authentication Required
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 3fd7baa..62226b8 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -1024,6 +1024,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"))
@@ -1339,12 +1348,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
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py
index 63e25b4..e6c4ec1 100644
--- a/Lib/test/test_urllib2net.py
+++ b/Lib/test/test_urllib2net.py
@@ -158,7 +158,7 @@ class OtherNetworkTests(unittest.TestCase):
req = urllib.request.Request(urlwith_frag)
res = urllib.request.urlopen(req)
self.assertEqual(res.geturl(),
- "http://docs.python.org/glossary.html")
+ "http://docs.python.org/glossary.html#glossary")
def test_custom_headers(self):
url = "http://www.example.com"