[3.13] Add yet few cases for urlparse/urlunparse roundtrip tests (GH-119031) (GH-119037)

(cherry picked from commit 331d385af9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-05-14 16:23:40 +02:00 committed by GitHub
parent 8720006062
commit 54839f0734
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 0 deletions

View File

@ -189,6 +189,9 @@ class UrlParseTestCase(unittest.TestCase):
('////path/to/file', ('////path/to/file',
('', '', '//path/to/file', '', '', ''), ('', '', '//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', '', '', ''), ('scheme', '', 'path/to/file', '', '', ''),
('scheme', '', 'path/to/file', '', '')), ('scheme', '', 'path/to/file', '', '')),
@ -201,6 +204,9 @@ class UrlParseTestCase(unittest.TestCase):
('scheme:////path/to/file', ('scheme:////path/to/file',
('scheme', '', '//path/to/file', '', '', ''), ('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', '', '', ''), ('file', '', '/tmp/junk.txt', '', '', ''),
('file', '', '/tmp/junk.txt', '', '')), ('file', '', '/tmp/junk.txt', '', '')),
@ -236,12 +242,23 @@ class UrlParseTestCase(unittest.TestCase):
'action=download-manifest&url=https://example.com/app', ''), 'action=download-manifest&url=https://example.com/app', ''),
('itms-services', '', '', ('itms-services', '', '',
'action=download-manifest&url=https://example.com/app', '')), '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): def _encode(t):
return (t[0].encode('ascii'), return (t[0].encode('ascii'),
tuple(x.encode('ascii') for x in t[1]), tuple(x.encode('ascii') for x in t[1]),
tuple(x.encode('ascii') for x in t[2])) tuple(x.encode('ascii') for x in t[2]))
bytes_cases = [_encode(x) for x in str_cases] 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: for url, parsed, split in str_cases + bytes_cases:
self.checkRoundtrips(url, parsed, split) self.checkRoundtrips(url, parsed, split)