| 192 | @pytest.mark.parametrize("blocksize", [None, 10]) |
| 193 | @pytest.mark.parametrize("fmt", compr) |
| 194 | def test_compression(fmt, blocksize): |
| 195 | if fmt not in compress: |
| 196 | pytest.skip("compression function not provided") |
| 197 | files2 = valmap(compress[fmt], files) |
| 198 | with filetexts(files2, mode="b"): |
| 199 | if fmt and blocksize: |
| 200 | with pytest.raises(ValueError): |
| 201 | read_bytes( |
| 202 | ".test.accounts.*.json", |
| 203 | blocksize=blocksize, |
| 204 | delimiter=b"\n", |
| 205 | compression=fmt, |
| 206 | ) |
| 207 | return |
| 208 | sample, values = read_bytes( |
| 209 | ".test.accounts.*.json", |
| 210 | blocksize=blocksize, |
| 211 | delimiter=b"\n", |
| 212 | compression=fmt, |
| 213 | ) |
| 214 | assert sample[:5] == files[sorted(files)[0]][:5] |
| 215 | assert sample.endswith(b"\n") |
| 216 | |
| 217 | results = compute(*concat(values)) |
| 218 | assert b"".join(results) == b"".join([files[k] for k in sorted(files)]) |
| 219 | |
| 220 | |
| 221 | def test_open_files(): |