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

Method test_read_readinto_readinto1

Lib/test/test_zstd.py:2384–2408  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2382 f.read(100)
2383
2384 def test_read_readinto_readinto1(self):
2385 lst = []
2386 with ZstdFile(io.BytesIO(COMPRESSED_THIS_FILE*5)) as f:
2387 while True:
2388 method = random.randint(0, 2)
2389 size = random.randint(0, 300)
2390
2391 if method == 0:
2392 dat = f.read(size)
2393 if not dat and size:
2394 break
2395 lst.append(dat)
2396 elif method == 1:
2397 ba = bytearray(size)
2398 read_size = f.readinto(ba)
2399 if read_size == 0 and size:
2400 break
2401 lst.append(bytes(ba[:read_size]))
2402 elif method == 2:
2403 ba = bytearray(size)
2404 read_size = f.readinto1(ba)
2405 if read_size == 0 and size:
2406 break
2407 lst.append(bytes(ba[:read_size]))
2408 self.assertEqual(b''.join(lst), THIS_FILE_BYTES*5)
2409
2410 def test_zstdfile_flush(self):
2411 # closed

Callers

nothing calls this directly

Calls 8

ZstdFileClass · 0.90
randintMethod · 0.80
readMethod · 0.45
appendMethod · 0.45
readintoMethod · 0.45
readinto1Method · 0.45
assertEqualMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected