diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_cgi.py | 24 | ||||
-rw-r--r-- | Lib/test/test_urlparse.py | 23 |
2 files changed, 23 insertions, 24 deletions
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py index cc11acc..ff2fc46 100644 --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -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 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', |