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:
@@ -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):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user