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

Fixed SortedDict.__copy__()

Fixed #18175 -- Calling SortedDict.__copy__() resulted in changes to
the original dictionary. The reason was likely related to subclassing
dict.

Thanks to linovia for report and patch.
This commit is contained in:
Anssi Kääriäinen
2012-04-30 17:12:38 +03:00
parent aa1aa1ad41
commit 4b11762f7d
2 changed files with 13 additions and 3 deletions

View File

@@ -111,6 +111,12 @@ class SortedDictTests(SimpleTestCase):
{7: 'seven', 1: 'one', 9: 'nine'}
)
def test_copy(self):
orig = SortedDict(((1, "one"), (0, "zero"), (2, "two")))
copied = copy.copy(orig)
self.assertEqual(orig.keys(), [1, 0, 2])
self.assertEqual(copied.keys(), [1, 0, 2])
def test_clear(self):
self.d1.clear()
self.assertEqual(self.d1, {})