From 4976ea825765df28e62eaba39fca57d4f0c8e348 Mon Sep 17 00:00:00 2001 From: ptweezy Date: Tue, 27 Oct 2026 15:43:28 -0400 Subject: [PATCH] Test threaded writes with blocks larger than the deflate window With 8 KiB blocks, the last 32 KiB of the previous block is the whole block, so the tests could not tell whether the writer took the dictionary from the end or the start of it. --- tests/test_igzip_threaded.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_igzip_threaded.py b/tests/test_igzip_threaded.py index dd26e95e..d7710a68 100644 --- a/tests/test_igzip_threaded.py +++ b/tests/test_igzip_threaded.py @@ -35,13 +35,16 @@ def test_threaded_read(): assert thread_data == data +@pytest.mark.parametrize("block_size", [8 * 1024, 64 * 1024]) @pytest.mark.parametrize(["mode", "threads"], list(itertools.product(["wb", "wt"], [1, 3, -1]))) -def test_threaded_write(tmp_path, mode, threads): +def test_threaded_write(tmp_path, mode, threads, block_size): with open(tmp_path / "output.gz", "wb") as tmp: - # Use a small block size to simulate many writes. + # Use small block sizes to simulate many writes. Each block uses up + # to 32 KiB from the end of the previous block as a dictionary, so + # also test a block size above 32 KiB. with igzip_threaded.open(tmp, mode, threads=threads, - block_size=8*1024) as out_file: + block_size=block_size) as out_file: gzip_open_mode = "rb" if "b" in mode else "rt" with gzip.open(TEST_FILE, gzip_open_mode) as in_file: while True: