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

Method test_dict_chunking

Lib/test/pickletester.py:3577–3598  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3575 self.assertTrue(num_appends >= 2)
3576
3577 def test_dict_chunking(self):
3578 n = 10 # too small to chunk
3579 x = dict.fromkeys(range(n))
3580 for proto in protocols:
3581 s = self.dumps(x, proto)
3582 self.assertIsInstance(s, bytes_types)
3583 y = self.loads(s)
3584 self.assert_is_copy(x, y)
3585 num_setitems = count_opcode(pickle.SETITEMS, s)
3586 self.assertEqual(num_setitems, proto > 0)
3587
3588 n = 2500 # expect at least two chunks when proto > 0
3589 x = dict.fromkeys(range(n))
3590 for proto in protocols:
3591 s = self.dumps(x, proto)
3592 y = self.loads(s)
3593 self.assert_is_copy(x, y)
3594 num_setitems = count_opcode(pickle.SETITEMS, s)
3595 if proto == 0:
3596 self.assertEqual(num_setitems, 0)
3597 else:
3598 self.assertTrue(num_setitems >= 2)
3599
3600 def test_set_chunking(self):
3601 n = 10 # too small to chunk

Callers

nothing calls this directly

Calls 8

count_opcodeFunction · 0.85
assertIsInstanceMethod · 0.80
assert_is_copyMethod · 0.80
assertTrueMethod · 0.80
fromkeysMethod · 0.45
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected