mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
to the urlparse one. Added a DeprecationWarning in the old module, it will be deprecated in the future. Docs and tests updated.
This commit is contained in:
parent
849f79a5d6
commit
c469d4c3aa
7 changed files with 159 additions and 131 deletions
|
@ -53,25 +53,6 @@ def do_test(buf, method):
|
|||
except Exception as err:
|
||||
return ComparableException(err)
|
||||
|
||||
# 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')]),
|
||||
("a=%26&b=%3D", [('a', '&'), ('b', '=')]),
|
||||
("a=%C3%BC&b=%CA%83", [('a', '\xfc'), ('b', '\u0283')]),
|
||||
]
|
||||
|
||||
parse_strict_test_cases = [
|
||||
("", ValueError("bad query field: ''")),
|
||||
("&", ValueError("bad query field: ''")),
|
||||
|
@ -141,11 +122,6 @@ def gen_result(data, environ):
|
|||
|
||||
class CgiTests(unittest.TestCase):
|
||||
|
||||
def test_qsl(self):
|
||||
for orig, expect in parse_qsl_test_cases:
|
||||
result = cgi.parse_qsl(orig, keep_blank_values=True)
|
||||
self.assertEqual(result, expect, "Error parsing %s" % repr(orig))
|
||||
|
||||
def test_strict(self):
|
||||
for orig, expect in parse_strict_test_cases:
|
||||
# Test basic parsing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue