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

Method test_read_readinto_readinto1

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

Source from the content-addressed store, hash-verified

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