MCPcopy Create free account
hub / github.com/dask/dask / test_read_block

Function test_read_block

dask/bytes/tests/test_bytes_utils.py:16–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14
15
16def test_read_block():
17 delimiter = b"\n"
18 data = delimiter.join([b"123", b"456", b"789"])
19 f = io.BytesIO(data)
20
21 assert read_block(f, 1, 2) == b"23"
22 assert read_block(f, 0, 1, delimiter=b"\n") == b"123\n"
23 assert read_block(f, 0, 2, delimiter=b"\n") == b"123\n"
24 assert read_block(f, 0, 3, delimiter=b"\n") == b"123\n"
25 assert read_block(f, 0, 5, delimiter=b"\n") == b"123\n456\n"
26 assert read_block(f, 0, 8, delimiter=b"\n") == b"123\n456\n789"
27 assert read_block(f, 0, 100, delimiter=b"\n") == b"123\n456\n789"
28 assert read_block(f, 1, 1, delimiter=b"\n") == b""
29 assert read_block(f, 1, 5, delimiter=b"\n") == b"456\n"
30 assert read_block(f, 1, 8, delimiter=b"\n") == b"456\n789"
31
32 for ols in [[(0, 3), (3, 3), (6, 3), (9, 2)], [(0, 4), (4, 4), (8, 4)]]:
33 out = [read_block(f, o, l, b"\n") for o, l in ols]
34 assert b"".join(filter(None, out)) == data
35
36
37def test_seek_delimiter_endline():

Callers

nothing calls this directly

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected