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

Method test_pickler

Lib/test/test_pickle.py:509–524  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

507 check_sizeof = support.check_sizeof
508
509 def test_pickler(self):
510 basesize = support.calcobjsize('7P2n3i2n4i2P')
511 p = _pickle.Pickler(io.BytesIO())
512 self.assertEqual(object.__sizeof__(p), basesize)
513 MT_size = struct.calcsize('3nP0n')
514 ME_size = struct.calcsize('Pn0P')
515 check = self.check_sizeof
516 check(p, basesize +
517 MT_size + 8 * ME_size + # Minimal memo table size.
518 sys.getsizeof(b'x'*4096)) # Minimal write buffer size.
519 for i in range(6):
520 p.dump(chr(i))
521 check(p, basesize +
522 MT_size + 32 * ME_size + # Size of memo table required to
523 # save references to 6 objects.
524 0) # Write buffer is cleared after every dump().
525
526 def test_unpickler(self):
527 basesize = support.calcobjsize('2P2n3P 2P2n2i5P 2P3n8P2n3i')

Callers

nothing calls this directly

Calls 4

checkFunction · 0.70
assertEqualMethod · 0.45
__sizeof__Method · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected