diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-18 16:31:41 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-18 16:31:41 (GMT) |
commit | 5d83d1a8141fa248356e4825857f166e4e65ec16 (patch) | |
tree | 91b9be2407ee79c3d7f422f77528ec38c495ffc8 /Lib/test/test_urlparse.py | |
parent | 2d1f0924691a214bbe6360233566b0c6241fbc47 (diff) | |
parent | ff97b08d0022392da23a25aa5ccb04e6a2966e8b (diff) | |
download | cpython-5d83d1a8141fa248356e4825857f166e4e65ec16.zip cpython-5d83d1a8141fa248356e4825857f166e4e65ec16.tar.gz cpython-5d83d1a8141fa248356e4825857f166e4e65ec16.tar.bz2 |
Issue #20270: urllib.urlparse now supports empty ports.
Diffstat (limited to 'Lib/test/test_urlparse.py')
-rw-r--r-- | Lib/test/test_urlparse.py | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index 19f67d3..3934811 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -394,6 +394,16 @@ class UrlParseTestCase(unittest.TestCase): ('http://[::12.34.56.78]/foo/', '::12.34.56.78', None), ('http://[::ffff:12.34.56.78]/foo/', '::ffff:12.34.56.78', None), + ('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), ] def _encode(t): return t[0].encode('ascii'), t[1].encode('ascii'), t[2] @@ -739,17 +749,25 @@ class UrlParseTestCase(unittest.TestCase): errors="ignore") self.assertEqual(result, [('key', '\u0141-')]) + def test_splitport(self): + splitport = urllib.parse.splitport + self.assertEqual(splitport('parrot:88'), ('parrot', '88')) + self.assertEqual(splitport('parrot'), ('parrot', None)) + self.assertEqual(splitport('parrot:'), ('parrot', None)) + self.assertEqual(splitport('127.0.0.1'), ('127.0.0.1', None)) + self.assertEqual(splitport('parrot:cheese'), ('parrot:cheese', None)) + def test_splitnport(self): - # Normal cases are exercised by other tests; ensure that we also - # catch cases with no port specified. (testcase ensuring coverage) - result = urllib.parse.splitnport('parrot:88') - self.assertEqual(result, ('parrot', 88)) - result = urllib.parse.splitnport('parrot') - self.assertEqual(result, ('parrot', -1)) - result = urllib.parse.splitnport('parrot', 55) - self.assertEqual(result, ('parrot', 55)) - result = urllib.parse.splitnport('parrot:') - self.assertEqual(result, ('parrot', None)) + splitnport = urllib.parse.splitnport + self.assertEqual(splitnport('parrot:88'), ('parrot', 88)) + self.assertEqual(splitnport('parrot'), ('parrot', -1)) + self.assertEqual(splitnport('parrot', 55), ('parrot', 55)) + self.assertEqual(splitnport('parrot:'), ('parrot', -1)) + self.assertEqual(splitnport('parrot:', 55), ('parrot', 55)) + self.assertEqual(splitnport('127.0.0.1'), ('127.0.0.1', -1)) + self.assertEqual(splitnport('127.0.0.1', 55), ('127.0.0.1', 55)) + self.assertEqual(splitnport('parrot:cheese'), ('parrot', None)) + self.assertEqual(splitnport('parrot:cheese', 55), ('parrot', None)) def test_splitquery(self): # Normal cases are exercised by other tests; ensure that we also |