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

Method test_set_chunking

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

Source from the content-addressed store, hash-verified

3332 self.assertTrue(num_setitems >= 2)
3333
3334 def test_set_chunking(self):
3335 n = 10 # too small to chunk
3336 x = set(range(n))
3337 for proto in protocols:
3338 s = self.dumps(x, proto)
3339 y = self.loads(s)
3340 self.assert_is_copy(x, y)
3341 num_additems = count_opcode(pickle.ADDITEMS, s)
3342 if proto < 4:
3343 self.assertEqual(num_additems, 0)
3344 else:
3345 self.assertEqual(num_additems, 1)
3346
3347 n = 2500 # expect at least two chunks when proto >= 4
3348 x = set(range(n))
3349 for proto in protocols:
3350 s = self.dumps(x, proto)
3351 y = self.loads(s)
3352 self.assert_is_copy(x, y)
3353 num_additems = count_opcode(pickle.ADDITEMS, s)
3354 if proto < 4:
3355 self.assertEqual(num_additems, 0)
3356 else:
3357 self.assertGreaterEqual(num_additems, 2)
3358
3359 def test_simple_newobj(self):
3360 x = SimpleNewObj.__new__(SimpleNewObj, 0xface) # avoid __init__

Callers

nothing calls this directly

Calls 7

setFunction · 0.85
count_opcodeFunction · 0.85
assert_is_copyMethod · 0.80
assertGreaterEqualMethod · 0.80
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected