Skip to content

Commit 4961eae

Browse files
committed
Add tests for errors during threading
1 parent 29f88ee commit 4961eae

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

tests/test_igzip_threaded.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import gzip
99
import io
10+
import tempfile
1011
from pathlib import Path
1112

1213
from isal import igzip_threaded
@@ -24,10 +25,22 @@ def test_threaded_read():
2425
assert thread_data == data
2526

2627

27-
def test_threaded_error():
28+
# Test whether threaded readers and writers throw an error rather than hang
29+
# indefinitely.
30+
31+
@pytest.mark.timeout(5)
32+
def test_threaded_read_error():
2833
with open(TEST_FILE, "rb") as f:
2934
data = f.read()
3035
truncated_data = data[:-8]
3136
with igzip_threaded.open(io.BytesIO(truncated_data), "rb") as tr_f:
3237
with pytest.raises(EOFError):
3338
tr_f.read()
39+
40+
41+
@pytest.mark.timeout(5)
42+
def test_threaded_write_error():
43+
tmp = tempfile.mktemp()
44+
with pytest.raises(ValueError) as error:
45+
with igzip_threaded.open(tmp, "wb", compresslevel=43) as writer:
46+
writer.write(b"x")

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ isolated_build=True
77

88
[testenv]
99
deps=pytest
10+
pytest-timeout
1011
coverage
1112
# Pass windows env variable for includes
1213
passenv=

0 commit comments

Comments
 (0)