| 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 |