Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add unit test for urlunsplit relative URL case.
  • Loading branch information
nascheme committed Jun 16, 2022
commit 00a3a92a8c37d8fadf9317e28afe89c1139c41e2
16 changes: 16 additions & 0 deletions Lib/test/test_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,22 @@ def test_urlsplit_normalization(self):
with self.assertRaises(ValueError):
urllib.parse.urlsplit(url)

def test_urlunsplit_relative(self):
cases = [
# expected result is a scheme/netloc relative URL
(('', 'a', '', '', ''), '//a'),
# extra leading slashes need to be stripped to avoid confusion
# with a relative URL
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confusion with a protocol-relative URL? [as opposed to a host-relative URL]

(('', '', '//a', '', ''), '/a'),
(('', '', '///a', '', ''), '/a'),
# not relative so extra leading slashes don't need stripping since
# they don't cause confusion
(('http', 'x.y', '//a', '', ''), 'http://x.y//a')
]
for parts, result in cases:
self.assertEqual(urllib.parse.urlunsplit(parts), result)
Comment thread
nascheme marked this conversation as resolved.
Outdated


class Utility_Tests(unittest.TestCase):
"""Testcase to test the various utility functions in the urllib."""
# In Python 2 this test class was in test_urllib.
Expand Down