summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_urllib.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index a684ed4..79e901f 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -379,7 +379,8 @@ class QuotingTests(unittest.TestCase):
result = urllib.parse.quote(quote_by_default, safe=quote_by_default)
self.assertEqual(quote_by_default, result,
"using quote(): %r != %r" % (quote_by_default, result))
- result = urllib.parse.quote_plus(quote_by_default, safe=quote_by_default)
+ result = urllib.parse.quote_plus(quote_by_default,
+ safe=quote_by_default)
self.assertEqual(quote_by_default, result,
"using quote_plus(): %r != %r" %
(quote_by_default, result))
@@ -411,7 +412,8 @@ class QuotingTests(unittest.TestCase):
for char in should_quote:
result = urllib.parse.quote(char)
self.assertEqual(hexescape(char), result,
- "using quote(): %s should be escaped to %s, not %s" %
+ "using quote(): "
+ "%s should be escaped to %s, not %s" %
(char, hexescape(char), result))
result = urllib.parse.quote_plus(char)
self.assertEqual(hexescape(char), result,
@@ -770,6 +772,21 @@ class urlencode_Tests(unittest.TestCase):
self.assertEqual(result.count('&'), 2,
"Expected 2 '&'s, got %s" % result.count('&'))
+ def test_empty_sequence(self):
+ self.assertEqual("", urllib.parse.urlencode({}))
+ self.assertEqual("", urllib.parse.urlencode([]))
+
+ def test_nonstring_values(self):
+ self.assertEqual("a=1", urllib.parse.urlencode({"a": 1}))
+ self.assertEqual("a=None", urllib.parse.urlencode({"a": None}))
+
+ def test_nonstring_seq_values(self):
+ self.assertEqual("a=1&a=2", urllib.parse.urlencode({"a": [1, 2]}, True))
+ self.assertEqual("a=None&a=a",
+ urllib.parse.urlencode({"a": [None, "a"]}, True))
+ self.assertEqual("a=a&a=b",
+ urllib.parse.urlencode({"a": {"a": 1, "b": 1}}, True))
+
class Pathname_Tests(unittest.TestCase):
"""Test pathname2url() and url2pathname()"""