summaryrefslogtreecommitdiff
path: root/Lib/test/test_copy.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-04 17:52:26 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-04 17:52:26 +0000
commitdca9de97b4256c8aad8a423d6f1d889d2bae9b3d (patch)
treea3bad4b9e4b5fe279288df47c64f569ab991e2c4 /Lib/test/test_copy.py
parentdd806cef090256f88dfe0ad88bdcba200be4cb78 (diff)
downloadcpython-git-dca9de97b4256c8aad8a423d6f1d889d2bae9b3d.tar.gz
Merged revisions 84495-84496 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84495 | antoine.pitrou | 2010-09-04 19:40:21 +0200 (sam., 04 sept. 2010) | 4 lines Issue #1100562: Fix deep-copying of objects derived from the list and dict types. Patch by Michele Orrù and Björn Lindqvist. ........ r84496 | antoine.pitrou | 2010-09-04 19:40:51 +0200 (sam., 04 sept. 2010) | 3 lines Fix Björn's name in ACKS. ........
Diffstat (limited to 'Lib/test/test_copy.py')
-rw-r--r--Lib/test/test_copy.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index e3503c4343..6b64f10112 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -526,6 +526,26 @@ class TestCopy(unittest.TestCase):
self.assertEqual(x.foo, y.foo)
self.assertTrue(x.foo is not y.foo)
+ def test_deepcopy_dict_subclass(self):
+ class C(dict):
+ def __init__(self, d=None):
+ if not d:
+ d = {}
+ self._keys = list(d.keys())
+ dict.__init__(self, d)
+ def __setitem__(self, key, item):
+ dict.__setitem__(self, key, item)
+ if key not in self._keys:
+ self._keys.append(key)
+ x = C(d={'foo':0})
+ y = copy.deepcopy(x)
+ self.assertEqual(x, y)
+ self.assertEqual(x._keys, y._keys)
+ self.assertTrue(x is not y)
+ x['bar'] = 1
+ self.assertNotEqual(x, y)
+ self.assertNotEqual(x._keys, y._keys)
+
def test_copy_list_subclass(self):
class C(list):
pass