summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urlparse.py
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-09-03 22:49:01 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-09-03 22:49:01 (GMT)
commitc469d4c3aa0a66579d1927f0e5d9630b3ea4024f (patch)
tree991fd708a1cad2f61d7ef86eceda43906c06d8de /Lib/test/test_urlparse.py
parent849f79a5d63deff924e1c62385af0441ee099bcf (diff)
downloadcpython-c469d4c3aa0a66579d1927f0e5d9630b3ea4024f.zip
cpython-c469d4c3aa0a66579d1927f0e5d9630b3ea4024f.tar.gz
cpython-c469d4c3aa0a66579d1927f0e5d9630b3ea4024f.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_urlparse.py')
-rw-r--r--Lib/test/test_urlparse.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index 103f89d..16bc133 100644
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -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,12 @@ 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 = urllib.parse.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',