Skip to content

Commit c257aee

Browse files
committed
Add threaded writer test
1 parent 1e8933d commit c257aee

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_igzip_threaded.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ def test_threaded_read():
2525
assert thread_data == data
2626

2727

28+
def test_threaded_write():
29+
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:
32+
while True:
33+
block = in_file.read(128 * 1024)
34+
if not block:
35+
break
36+
out_file.write(block)
37+
with gzip.open(TEST_FILE, "rt") as test_file:
38+
test_data = test_file.read()
39+
with gzip.open(tmp.name, "rt") as test_out:
40+
out_data = test_out.read()
41+
assert test_data == out_data
42+
43+
2844
# Test whether threaded readers and writers throw an error rather than hang
2945
# indefinitely.
3046

0 commit comments

Comments
 (0)