1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #12375 -- Added a dict() method to convert a MultiValueDict (such as a QueryDict) to a dictionary of key-value pairs. Thanks, oinopion and hvdklauw.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16418 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel
2011-06-16 16:34:55 +00:00
parent dfa29161e2
commit 97f22f2969
3 changed files with 30 additions and 0 deletions

View File

@@ -235,6 +235,18 @@ class MultiValueDictTests(DatastructuresTestCase):
self.assertEqual(d1["key"], ["Penguin"])
self.assertEqual(d2["key"], ["Penguin"])
def test_dict_translation(self):
mvd = MultiValueDict({
'devs': ['Bob', 'Joe'],
'pm': ['Rory'],
})
d = mvd.dict()
self.assertEqual(d.keys(), mvd.keys())
for key in mvd.keys():
self.assertEqual(d[key], mvd[key])
self.assertEqual({}, MultiValueDict().dict())
class DotExpandedDictTests(DatastructuresTestCase):