summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_copy.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-04 17:40:21 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-04 17:40:21 (GMT)
commit3941a8fece7e714583965565795f2986aa203cb1 (patch)
treee021f726f4c243bd475371e7300b82b8d16106d9 /Lib/test/test_copy.py
parente5a9101519ded4efc38611d2f93594f3fe04147f (diff)
downloadcpython-3941a8fece7e714583965565795f2986aa203cb1.zip
cpython-3941a8fece7e714583965565795f2986aa203cb1.tar.gz
cpython-3941a8fece7e714583965565795f2986aa203cb1.tar.bz2
Issue #1100562: Fix deep-copying of objects derived from the list and dict types.
Patch by Michele Orrù and Björn Lindqvist.
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 732b4f4..a84c109 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -532,6 +532,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())
+ super().__init__(d)
+ def __setitem__(self, key, item):
+ super().__setitem__(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