Skip to content

Commit 39d31e0

Browse files
committed
Add tests for oversized blocks
1 parent 71b7d61 commit 39d31e0

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tests/test_igzip_threaded.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,26 @@ def test_threaded_read_error():
7575
tr_f.read()
7676

7777

78+
@pytest.mark.timeout(5)
79+
@pytest.mark.parametrize("threads", [1, 3])
80+
def test_threaded_write_oversized_block_no_error(threads):
81+
with igzip_threaded.open(
82+
io.BytesIO(), "wb", compresslevel=3, threads=threads,
83+
block_size=8 * 1024
84+
) as writer:
85+
writer.write(os.urandom(1024 * 64))
86+
87+
7888
@pytest.mark.timeout(5)
7989
@pytest.mark.parametrize("threads", [1, 3])
8090
def test_threaded_write_error(threads):
81-
# parallel_deflate_and_crc method is called in a worker thread.
91+
f = igzip_threaded._ThreadedGzipWriter(
92+
fp=io.BytesIO(), level=3,
93+
threads=threads, buffer_size=8 * 1024)
94+
# Bypass the write method which should not allow this.
95+
f.input_queues[0].put((os.urandom(1024 * 64), b""))
8296
with pytest.raises(OverflowError) as error:
83-
with igzip_threaded.open(
84-
io.BytesIO(), "wb", compresslevel=3, threads=threads
85-
) as writer:
86-
writer.write(os.urandom(1024 * 1024 * 50))
97+
f.close()
8798
error.match("Compressed output exceeds buffer size")
8899

89100

0 commit comments

Comments
 (0)