@@ -25,10 +25,11 @@ def test_threaded_read():
25
25
assert thread_data == data
26
26
27
27
28
- def test_threaded_write ():
28
+ @pytest .mark .parametrize ("mode" , ["wb" , "wt" ])
29
+ def test_threaded_write (mode ):
29
30
with tempfile .NamedTemporaryFile ("wb" , delete = False ) as tmp :
30
- with igzip_threaded .open (tmp , "wb" , threads = 3 ) as out_file :
31
- with gzip .open (TEST_FILE ) as in_file :
31
+ with igzip_threaded .open (tmp , mode , threads = 3 ) as out_file :
32
+ with gzip .open (TEST_FILE , "rb" if "b" in mode else "rt" ) as in_file :
32
33
while True :
33
34
block = in_file .read (128 * 1024 )
34
35
if not block :
@@ -41,6 +42,22 @@ def test_threaded_write():
41
42
assert test_data == out_data
42
43
43
44
45
+ def test_threaded_open_no_threads ():
46
+ with tempfile .TemporaryFile ("rb" ) as tmp :
47
+ klass = igzip_threaded .open (tmp , "rb" , threads = 0 )
48
+ # igzip.IGzipFile inherits gzip.Gzipfile
49
+ assert isinstance (klass , gzip .GzipFile )
50
+
51
+
52
+ def test_threaded_open_not_a_file_or_pathlike ():
53
+ i_am_a_tuple = (1 , 2 , 3 )
54
+ with pytest .raises (TypeError ) as error :
55
+ igzip_threaded .open (i_am_a_tuple )
56
+ error .match ("str" )
57
+ error .match ("bytes" )
58
+ error .match ("file" )
59
+
60
+
44
61
# Test whether threaded readers and writers throw an error rather than hang
45
62
# indefinitely.
46
63
0 commit comments