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

Method test_copy_and_pickle

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

Source from the content-addressed store, hash-verified

8405 NamedTuple('Name', [], y=str)
8406
8407 def test_copy_and_pickle(self):
8408 global Emp # pickle wants to reference the class by name
8409 Emp = NamedTuple('Emp', [('name', str), ('cool', int)])
8410 for cls in Emp, CoolEmployee, self.NestedEmployee:
8411 with self.subTest(cls=cls):
8412 jane = cls('jane', 37)
8413 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
8414 z = pickle.dumps(jane, proto)
8415 jane2 = pickle.loads(z)
8416 self.assertEqual(jane2, jane)
8417 self.assertIsInstance(jane2, cls)
8418
8419 jane2 = copy(jane)
8420 self.assertEqual(jane2, jane)
8421 self.assertIsInstance(jane2, cls)
8422
8423 jane2 = deepcopy(jane)
8424 self.assertEqual(jane2, jane)
8425 self.assertIsInstance(jane2, cls)
8426
8427 def test_orig_bases(self):
8428 T = TypeVar('T')

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected