File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 7
7
8
8
import gzip
9
9
import io
10
+ import tempfile
10
11
from pathlib import Path
11
12
12
13
from isal import igzip_threaded
@@ -24,10 +25,22 @@ def test_threaded_read():
24
25
assert thread_data == data
25
26
26
27
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 ():
28
33
with open (TEST_FILE , "rb" ) as f :
29
34
data = f .read ()
30
35
truncated_data = data [:- 8 ]
31
36
with igzip_threaded .open (io .BytesIO (truncated_data ), "rb" ) as tr_f :
32
37
with pytest .raises (EOFError ):
33
38
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" )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ isolated_build=True
7
7
8
8
[testenv]
9
9
deps =pytest
10
+ pytest-timeout
10
11
coverage
11
12
# Pass windows env variable for includes
12
13
passenv =
You can’t perform that action at this time.
0 commit comments