Skip to content

Commit ea30d6f

Browse files
committed
Reproduce faulty flushing behavior
1 parent 5461a6e commit ea30d6f

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
@@ -239,3 +239,19 @@ def test_threaded_program_can_exit_on_error(tmp_path, mode, threads):
239239
)
240240
f.write("raise Exception('Error')\n")
241241
subprocess.run([sys.executable, str(program)])
242+
243+
244+
@pytest.mark.parametrize("threads", [1, 2])
245+
def test_flush(tmp_path, threads):
246+
test_file = tmp_path / "output.gz"
247+
with igzip_threaded.open(test_file, "wb", threads=threads) as f:
248+
f.write(b"1")
249+
f.flush()
250+
assert gzip.decompress(test_file.read_bytes()) == b"1"
251+
f.write(b"2")
252+
f.flush()
253+
assert gzip.decompress(test_file.read_bytes()) == b"12"
254+
f.write(b"3")
255+
f.flush()
256+
assert gzip.decompress(test_file.read_bytes()) == b"123"
257+
assert gzip.decompress(test_file.read_bytes()) == b"123"

0 commit comments

Comments
 (0)