Skip to content
Merged
Changes from all commits
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
Add yet few cases for urlparse/urlunparse roundtrip tests (GH-119031)
Add yet few cases for urlparse/urlunparse tests
(cherry picked from commit 331d385)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
serhiy-storchaka authored and miss-islington committed May 14, 2024
commit 80ebe656c56011e654c08fb0b575d623434e572b
17 changes: 17 additions & 0 deletions Lib/test/test_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ def test_roundtrips(self):
('////path/to/file',
('', '', '//path/to/file', '', '', ''),
('', '', '//path/to/file', '', '')),
('/////path/to/file',
('', '', '///path/to/file', '', '', ''),
('', '', '///path/to/file', '', '')),
('scheme:path/to/file',
('scheme', '', 'path/to/file', '', '', ''),
('scheme', '', 'path/to/file', '', '')),
Expand All @@ -201,6 +204,9 @@ def test_roundtrips(self):
('scheme:////path/to/file',
('scheme', '', '//path/to/file', '', '', ''),
('scheme', '', '//path/to/file', '', '')),
('scheme://///path/to/file',
('scheme', '', '///path/to/file', '', '', ''),
('scheme', '', '///path/to/file', '', '')),
('file:///tmp/junk.txt',
('file', '', '/tmp/junk.txt', '', '', ''),
('file', '', '/tmp/junk.txt', '', '')),
Expand Down Expand Up @@ -236,12 +242,23 @@ def test_roundtrips(self):
'action=download-manifest&url=https://example.com/app', ''),
('itms-services', '', '',
'action=download-manifest&url=https://example.com/app', '')),
('+scheme:path/to/file',
('', '', '+scheme:path/to/file', '', '', ''),
('', '', '+scheme:path/to/file', '', '')),
('sch_me:path/to/file',
('', '', 'sch_me:path/to/file', '', '', ''),
('', '', 'sch_me:path/to/file', '', '')),
]
def _encode(t):
return (t[0].encode('ascii'),
tuple(x.encode('ascii') for x in t[1]),
tuple(x.encode('ascii') for x in t[2]))
bytes_cases = [_encode(x) for x in str_cases]
str_cases += [
('schème:path/to/file',
('', '', 'schème:path/to/file', '', '', ''),
('', '', 'schème:path/to/file', '', '')),
]
for url, parsed, split in str_cases + bytes_cases:
self.checkRoundtrips(url, parsed, split)

Expand Down