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

Method test_copy_inst_getnewargs

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

Source from the content-addressed store, hash-verified

197 self.assertEqual(copy.copy(x), x)
198
199 def test_copy_inst_getnewargs(self):
200 class C(int):
201 def __new__(cls, foo):
202 self = int.__new__(cls)
203 self.foo = foo
204 return self
205 def __getnewargs__(self):
206 return self.foo,
207 def __eq__(self, other):
208 return self.foo == other.foo
209 x = C(42)
210 y = copy.copy(x)
211 self.assertIsInstance(y, C)
212 self.assertEqual(y, x)
213 self.assertIsNot(y, x)
214 self.assertEqual(y.foo, x.foo)
215
216 def test_copy_inst_getnewargs_ex(self):
217 class C(int):

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