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

Method test_set_chunking

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

Source from the content-addressed store, hash-verified

3598 self.assertTrue(num_setitems >= 2)
3599
3600 def test_set_chunking(self):
3601 n = 10 # too small to chunk
3602 x = set(range(n))
3603 for proto in protocols:
3604 s = self.dumps(x, proto)
3605 y = self.loads(s)
3606 self.assert_is_copy(x, y)
3607 num_additems = count_opcode(pickle.ADDITEMS, s)
3608 if proto < 4:
3609 self.assertEqual(num_additems, 0)
3610 else:
3611 self.assertEqual(num_additems, 1)
3612
3613 n = 2500 # expect at least two chunks when proto >= 4
3614 x = set(range(n))
3615 for proto in protocols:
3616 s = self.dumps(x, proto)
3617 y = self.loads(s)
3618 self.assert_is_copy(x, y)
3619 num_additems = count_opcode(pickle.ADDITEMS, s)
3620 if proto < 4:
3621 self.assertEqual(num_additems, 0)
3622 else:
3623 self.assertGreaterEqual(num_additems, 2)
3624
3625 def test_simple_newobj(self):
3626 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