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

Method test_copy_and_pickle

Lib/test/test_typing.py:8377–8395  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

8375 NamedTuple(typename='Emp', name=str, id=int)
8376
8377 def test_copy_and_pickle(self):
8378 global Emp # pickle wants to reference the class by name
8379 Emp = NamedTuple('Emp', [('name', str), ('cool', int)])
8380 for cls in Emp, CoolEmployee, self.NestedEmployee:
8381 with self.subTest(cls=cls):
8382 jane = cls('jane', 37)
8383 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
8384 z = pickle.dumps(jane, proto)
8385 jane2 = pickle.loads(z)
8386 self.assertEqual(jane2, jane)
8387 self.assertIsInstance(jane2, cls)
8388
8389 jane2 = copy(jane)
8390 self.assertEqual(jane2, jane)
8391 self.assertIsInstance(jane2, cls)
8392
8393 jane2 = deepcopy(jane)
8394 self.assertEqual(jane2, jane)
8395 self.assertIsInstance(jane2, cls)
8396
8397 def test_orig_bases(self):
8398 T = TypeVar('T')

Callers

nothing calls this directly

Calls 9

NamedTupleFunction · 0.90
copyFunction · 0.90
deepcopyFunction · 0.90
subTestMethod · 0.80
assertIsInstanceMethod · 0.80
clsClass · 0.50
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected