diff --git a/django/utils/http.py b/django/utils/http.py
index d343a37..9da5a14 100644
a
|
b
|
def urlencode(query, doseq=0):
|
71 | 71 | query = query.items() |
72 | 72 | return urllib.urlencode( |
73 | 73 | [(smart_str(k), |
74 | | isinstance(v, (list,tuple)) and [smart_str(i) for i in v] or smart_str(v)) |
| 74 | [smart_str(i) for i in v] if isinstance(v, (list,tuple)) else smart_str(v)) |
75 | 75 | for k, v in query], |
76 | 76 | doseq) |
77 | 77 | |
diff --git a/tests/regressiontests/utils/http.py b/tests/regressiontests/utils/http.py
index 16c7daa..67dcd7a 100644
a
|
b
|
class TestUtilsHttp(unittest.TestCase):
|
31 | 31 | # 2-tuples (the norm) |
32 | 32 | result = http.urlencode((('a', 1), ('b', 2), ('c', 3))) |
33 | 33 | self.assertEqual(result, 'a=1&b=2&c=3') |
| 34 | |
34 | 35 | # A dictionary |
35 | 36 | result = http.urlencode({ 'a': 1, 'b': 2, 'c': 3}) |
36 | 37 | acceptable_results = [ |
… |
… |
class TestUtilsHttp(unittest.TestCase):
|
44 | 45 | 'c=3&b=2&a=1' |
45 | 46 | ] |
46 | 47 | self.assertTrue(result in acceptable_results) |
| 48 | result = http.urlencode({'a': [1, 2]}, doseq=False) |
| 49 | self.assertEqual(result, 'a=%5B%271%27%2C+%272%27%5D') |
| 50 | result = http.urlencode({'a': [1, 2]}, doseq=True) |
| 51 | self.assertEqual(result, 'a=1&a=2') |
| 52 | result = http.urlencode({'a': []}, doseq=True) |
| 53 | self.assertEqual(result, '') |
| 54 | |
47 | 55 | # A MultiValueDict |
48 | 56 | result = http.urlencode(MultiValueDict({ |
49 | 57 | 'name': ['Adrian', 'Simon'], |