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

Method test_huge_str_32b

Lib/test/pickletester.py:4719–4739  ·  view source on GitHub ↗
(self, size)

Source from the content-addressed store, hash-verified

4717
4718 @bigmemtest(size=_2G, memuse=8, dry_run=False)
4719 def test_huge_str_32b(self, size):
4720 data = "abcd" * (size // 4)
4721 try:
4722 for proto in protocols:
4723 if proto == 0:
4724 continue
4725 with self.subTest(proto=proto):
4726 try:
4727 pickled = self.dumps(data, protocol=proto)
4728 header = (pickle.BINUNICODE +
4729 struct.pack("<I", len(data)))
4730 data_start = pickled.index(b'abcd')
4731 self.assertEqual(
4732 header,
4733 pickled[data_start-len(header):data_start])
4734 self.assertEqual((pickled.rindex(b"abcd") + len(b"abcd") -
4735 pickled.index(b"abcd")), len(data))
4736 finally:
4737 pickled = None
4738 finally:
4739 data = None
4740
4741 # BINUNICODE (protocols 1, 2 and 3) cannot carry more than 2**32 - 1 bytes
4742 # of utf-8 encoded unicode. BINUNICODE8 (protocol 4) supports these huge

Callers

nothing calls this directly

Calls 6

subTestMethod · 0.45
dumpsMethod · 0.45
packMethod · 0.45
indexMethod · 0.45
assertEqualMethod · 0.45
rindexMethod · 0.45

Tested by

no test coverage detected