MCPcopy Index your code
hub / github.com/python/cpython / test_copy_inst_getnewargs_ex

Method test_copy_inst_getnewargs_ex

Lib/test/test_copy.py:216–231  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

214 self.assertEqual(y.foo, x.foo)
215
216 def test_copy_inst_getnewargs_ex(self):
217 class C(int):
218 def __new__(cls, *, foo):
219 self = int.__new__(cls)
220 self.foo = foo
221 return self
222 def __getnewargs_ex__(self):
223 return (), {'foo': self.foo}
224 def __eq__(self, other):
225 return self.foo == other.foo
226 x = C(foo=42)
227 y = copy.copy(x)
228 self.assertIsInstance(y, C)
229 self.assertEqual(y, x)
230 self.assertIsNot(y, x)
231 self.assertEqual(y.foo, x.foo)
232
233 def test_copy_inst_getstate(self):
234 class C:

Callers

nothing calls this directly

Calls 5

assertIsInstanceMethod · 0.80
assertIsNotMethod · 0.80
CClass · 0.70
copyMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected