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

Method test_copy_inst_getnewargs

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

Source from the content-addressed store, hash-verified

191 self.assertEqual(copy.copy(x), x)
192
193 def test_copy_inst_getnewargs(self):
194 class C(int):
195 def __new__(cls, foo):
196 self = int.__new__(cls)
197 self.foo = foo
198 return self
199 def __getnewargs__(self):
200 return self.foo,
201 def __eq__(self, other):
202 return self.foo == other.foo
203 x = C(42)
204 y = copy.copy(x)
205 self.assertIsInstance(y, C)
206 self.assertEqual(y, x)
207 self.assertIsNot(y, x)
208 self.assertEqual(y.foo, x.foo)
209
210 def test_copy_inst_getnewargs_ex(self):
211 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