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

Method test_dict_chunking

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

Source from the content-addressed store, hash-verified

3309 self.assertTrue(num_appends >= 2)
3310
3311 def test_dict_chunking(self):
3312 n = 10 # too small to chunk
3313 x = dict.fromkeys(range(n))
3314 for proto in protocols:
3315 s = self.dumps(x, proto)
3316 self.assertIsInstance(s, bytes_types)
3317 y = self.loads(s)
3318 self.assert_is_copy(x, y)
3319 num_setitems = count_opcode(pickle.SETITEMS, s)
3320 self.assertEqual(num_setitems, proto > 0)
3321
3322 n = 2500 # expect at least two chunks when proto > 0
3323 x = dict.fromkeys(range(n))
3324 for proto in protocols:
3325 s = self.dumps(x, proto)
3326 y = self.loads(s)
3327 self.assert_is_copy(x, y)
3328 num_setitems = count_opcode(pickle.SETITEMS, s)
3329 if proto == 0:
3330 self.assertEqual(num_setitems, 0)
3331 else:
3332 self.assertTrue(num_setitems >= 2)
3333
3334 def test_set_chunking(self):
3335 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