summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urlparse.py
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-04-16 03:06:19 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-04-16 03:06:19 (GMT)
commit2176ad5f304880bcc2341106ba4ed943ded8a120 (patch)
tree09c0b5e01bb06ccc2608f29827dfe68454a2f812 /Lib/test/test_urlparse.py
parent0e3e48545295d23e2dae081a01b6e62fb2dfe65a (diff)
downloadcpython-2176ad5f304880bcc2341106ba4ed943ded8a120.zip
cpython-2176ad5f304880bcc2341106ba4ed943ded8a120.tar.gz
cpython-2176ad5f304880bcc2341106ba4ed943ded8a120.tar.bz2
Merged revisions 80102 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r80102 | senthil.kumaran | 2010-04-16 08:32:13 +0530 (Fri, 16 Apr 2010) | 9 lines Merged revisions 80101 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r80101 | senthil.kumaran | 2010-04-16 08:16:46 +0530 (Fri, 16 Apr 2010) | 3 lines Fix issue2987: RFC2732 support for urlparse (IPv6 addresses) ........ ................
Diffstat (limited to 'Lib/test/test_urlparse.py')
-rw-r--r--Lib/test/test_urlparse.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index 1cac691..14c2d2b 100644
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -239,10 +239,44 @@ class UrlParseTestCase(unittest.TestCase):
#self.checkJoin(RFC2396_BASE, '?y', 'http://a/b/c/?y')
#self.checkJoin(RFC2396_BASE, ';x', 'http://a/b/c/;x')
+
def test_RFC3986(self):
self.checkJoin(RFC3986_BASE, '?y','http://a/b/c/d;p?y')
self.checkJoin(RFC2396_BASE, ';x', 'http://a/b/c/;x')
+ def test_RFC2732(self):
+ for url, hostname, port in [
+ ('http://Test.python.org:5432/foo/', 'test.python.org', 5432),
+ ('http://12.34.56.78:5432/foo/', '12.34.56.78', 5432),
+ ('http://[::1]:5432/foo/', '::1', 5432),
+ ('http://[dead:beef::1]:5432/foo/', 'dead:beef::1', 5432),
+ ('http://[dead:beef::]:5432/foo/', 'dead:beef::', 5432),
+ ('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:5432/foo/',
+ 'dead:beef:cafe:5417:affe:8fa3:deaf:feed', 5432),
+ ('http://[::12.34.56.78]:5432/foo/', '::12.34.56.78', 5432),
+ ('http://[::ffff:12.34.56.78]:5432/foo/',
+ '::ffff:12.34.56.78', 5432),
+ ('http://Test.python.org/foo/', 'test.python.org', None),
+ ('http://12.34.56.78/foo/', '12.34.56.78', None),
+ ('http://[::1]/foo/', '::1', None),
+ ('http://[dead:beef::1]/foo/', 'dead:beef::1', None),
+ ('http://[dead:beef::]/foo/', 'dead:beef::', None),
+ ('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/',
+ 'dead:beef:cafe:5417:affe:8fa3:deaf:feed', None),
+ ('http://[::12.34.56.78]/foo/', '::12.34.56.78', None),
+ ('http://[::ffff:12.34.56.78]/foo/',
+ '::ffff:12.34.56.78', None),
+ ]:
+ urlparsed = urllib.parse.urlparse(url)
+ self.assertEqual((urlparsed.hostname, urlparsed.port) , (hostname, port))
+
+ for invalid_url in [
+ 'http://::12.34.56.78]/',
+ 'http://[::1/foo/',
+ 'http://[::ffff:12.34.56.78']:
+ self.assertRaises(ValueError, lambda : urllib.parse.urlparse(invalid_url).hostname)
+ self.assertRaises(ValueError, lambda : urllib.parse.urlparse(invalid_url))
+
def test_urldefrag(self):
for url, defrag, frag in [
('http://python.org#frag', 'http://python.org', 'frag'),