MCPcopy
hub / github.com/dask/dask / test_read_bytes_delimited

Function test_read_bytes_delimited

dask/bytes/tests/test_s3.py:343–379  ·  view source on GitHub ↗
(s3, blocksize, s3so)

Source from the content-addressed store, hash-verified

341
342@pytest.mark.parametrize("blocksize", [5, 15, 45, 1500])
343def test_read_bytes_delimited(s3, blocksize, s3so):
344 _, values = read_bytes(
345 f"s3://{test_bucket_name}/test/accounts*",
346 blocksize=blocksize,
347 delimiter=b"\n",
348 **s3so,
349 )
350 _, values2 = read_bytes(
351 f"s3://{test_bucket_name}/test/accounts*",
352 blocksize=blocksize,
353 delimiter=b"foo",
354 **s3so,
355 )
356 assert [a.key for a in concat(values)] != [b.key for b in concat(values2)]
357
358 results = compute(*concat(values))
359 res = [r for r in results if r]
360 assert all(r.endswith(b"\n") for r in res)
361 ourlines = b"".join(res).split(b"\n")
362 testlines = b"".join(files[k] for k in sorted(files)).split(b"\n")
363 assert ourlines == testlines
364
365 # delimiter not at the end
366 d = b"}"
367 _, values = read_bytes(
368 f"s3://{test_bucket_name}/test/accounts*",
369 blocksize=blocksize,
370 delimiter=d,
371 **s3so,
372 )
373 results = compute(*concat(values))
374 res = [r for r in results if r]
375 # All should end in } except EOF
376 assert sum(r.endswith(b"}") for r in res) == len(res) - 2
377 ours = b"".join(res)
378 test = b"".join(files[v] for v in sorted(files))
379 assert ours == test
380
381
382@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 7

read_bytesFunction · 0.90
computeFunction · 0.90
allFunction · 0.85
splitMethod · 0.80
concatFunction · 0.50
sumFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…