mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
to the urlparse one. Added a PendingDeprecationWarning in the old module, it will be deprecated in the future. Docs and tests updated.
This commit is contained in:
parent
69acb43327
commit
c585df9476
8 changed files with 177 additions and 128 deletions
|
@ -8,6 +8,23 @@ RFC1808_BASE = "http://a/b/c/d;p?q#f"
|
|||
RFC2396_BASE = "http://a/b/c/d;p?q"
|
||||
RFC3986_BASE = "http://a/b/c/d;p?q"
|
||||
|
||||
# A list of test cases. Each test case is a a two-tuple that contains
|
||||
# a string with the query and a dictionary with the expected result.
|
||||
|
||||
parse_qsl_test_cases = [
|
||||
("", []),
|
||||
("&", []),
|
||||
("&&", []),
|
||||
("=", [('', '')]),
|
||||
("=a", [('', 'a')]),
|
||||
("a", [('a', '')]),
|
||||
("a=", [('a', '')]),
|
||||
("a=", [('a', '')]),
|
||||
("&a=b", [('a', 'b')]),
|
||||
("a=a+b&b=b+c", [('a', 'a b'), ('b', 'b c')]),
|
||||
("a=1&a=2", [('a', '1'), ('a', '2')]),
|
||||
]
|
||||
|
||||
class UrlParseTestCase(unittest.TestCase):
|
||||
|
||||
def checkRoundtrips(self, url, parsed, split):
|
||||
|
@ -61,6 +78,11 @@ class UrlParseTestCase(unittest.TestCase):
|
|||
self.assertEqual(result3.hostname, result.hostname)
|
||||
self.assertEqual(result3.port, result.port)
|
||||
|
||||
def test_qsl(self):
|
||||
for orig, expect in parse_qsl_test_cases:
|
||||
result = urlparse.parse_qsl(orig, keep_blank_values=True)
|
||||
self.assertEqual(result, expect, "Error parsing %s" % repr(orig))
|
||||
|
||||
def test_roundtrips(self):
|
||||
testcases = [
|
||||
('file:///tmp/junk.txt',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue