1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed MultiValueDict's copy implementation to be consistant with all other copies.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14366 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor
2010-10-27 20:39:20 +00:00
parent 3d69b21790
commit c6f90f0053
2 changed files with 28 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ Tests for stuff in django.utils.datastructures.
import pickle
import unittest
from django.utils.copycompat import copy
from django.utils.datastructures import *
@@ -211,6 +212,26 @@ class MultiValueDictTests(DatastructuresTestCase):
self.assertEquals(list(d.itervalues()),
['Developer', 'Simon', 'Willison'])
def test_copy(self):
for copy_func in [copy, lambda d: d.copy()]:
d1 = MultiValueDict({
"developers": ["Carl", "Fred"]
})
self.assertEqual(d1["developers"], "Fred")
d2 = copy_func(d1)
d2.update({"developers": "Groucho"})
self.assertEqual(d2["developers"], "Groucho")
self.assertEqual(d1["developers"], "Fred")
d1 = MultiValueDict({
"key": [[]]
})
self.assertEqual(d1["key"], [])
d2 = copy_func(d1)
d2["key"].append("Penguin")
self.assertEqual(d1["key"], ["Penguin"])
self.assertEqual(d2["key"], ["Penguin"])
class DotExpandedDictTests(DatastructuresTestCase):