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

Method _test_recursive_dict_key

Lib/test/pickletester.py:2730–2742  ·  view source on GitHub ↗
(self, cls, asdict=identity, minprotocol=0)

Source from the content-addressed store, hash-verified

2728 self._test_recursive_tuple_and_dict(REX_seven, asdict=lambda x: x.table)
2729
2730 def _test_recursive_dict_key(self, cls, asdict=identity, minprotocol=0):
2731 # Dict containing an immutable object (as key) containing the original
2732 # dict.
2733 d = cls()
2734 d[K(d)] = 1
2735 for proto in range(minprotocol, pickle.HIGHEST_PROTOCOL + 1):
2736 s = self.dumps(d, proto)
2737 x = self.loads(s)
2738 self.assertIsInstance(x, cls)
2739 y = asdict(x)
2740 self.assertEqual(len(y.keys()), 1)
2741 self.assertIsInstance(list(y.keys())[0], K)
2742 self.assertIs(list(y.keys())[0].value, x)
2743
2744 def test_recursive_dict_key(self):
2745 self._test_recursive_dict_key(dict)

Calls 10

asdictFunction · 0.85
listClass · 0.85
assertIsInstanceMethod · 0.80
KClass · 0.70
clsClass · 0.50
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45
keysMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected