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

Method test_huge_str_32b

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

Source from the content-addressed store, hash-verified

4195
4196 @bigmemtest(size=_2G, memuse=8, dry_run=False)
4197 def test_huge_str_32b(self, size):
4198 data = "abcd" * (size // 4)
4199 try:
4200 for proto in protocols:
4201 if proto == 0:
4202 continue
4203 with self.subTest(proto=proto):
4204 try:
4205 pickled = self.dumps(data, protocol=proto)
4206 header = (pickle.BINUNICODE +
4207 struct.pack("<I", len(data)))
4208 data_start = pickled.index(b'abcd')
4209 self.assertEqual(
4210 header,
4211 pickled[data_start-len(header):data_start])
4212 self.assertEqual((pickled.rindex(b"abcd") + len(b"abcd") -
4213 pickled.index(b"abcd")), len(data))
4214 finally:
4215 pickled = None
4216 finally:
4217 data = None
4218
4219 # BINUNICODE (protocols 1, 2 and 3) cannot carry more than 2**32 - 1 bytes
4220 # of utf-8 encoded unicode. BINUNICODE8 (protocol 4) supports these huge

Callers

nothing calls this directly

Calls 7

lenFunction · 0.85
subTestMethod · 0.80
dumpsMethod · 0.45
packMethod · 0.45
indexMethod · 0.45
assertEqualMethod · 0.45
rindexMethod · 0.45

Tested by

no test coverage detected