MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_deepcopy_grow

Method test_deepcopy_grow

Lib/test/test_xml_etree.py:3123–3146  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3121 self.assertListEqual(list(c), [evil])
3122
3123 def test_deepcopy_grow(self):
3124 # Prevent crashes when __deepcopy__() mutates the children list.
3125 # See https://github.com/python/cpython/issues/133009.
3126 a = ET.Element('a')
3127 b = ET.Element('b')
3128 c = ET.Element('c')
3129
3130 class X(ET.Element):
3131 def __deepcopy__(self, memo):
3132 root.append(a)
3133 root.append(b)
3134 return self
3135
3136 root = ET.Element('top')
3137 evil1, evil2 = X('1'), X('2')
3138 root.extend([evil1, c, evil2])
3139 children = list(copy.deepcopy(root))
3140 # mock deep copies
3141 self.assertIs(children[0], evil1)
3142 self.assertIs(children[2], evil2)
3143 # true deep copies
3144 self.assertEqual(children[1].tag, c.tag)
3145 self.assertEqual([c.tag for c in children[3:]],
3146 [a.tag, b.tag, a.tag, b.tag])
3147
3148
3149class MutationDeleteElementPath(str):

Callers

nothing calls this directly

Calls 5

extendMethod · 0.95
listClass · 0.85
XClass · 0.70
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected