Skip to content

Commit e30fbc4

Browse files
committed
Add check for truncated stream
1 parent 000c141 commit e30fbc4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_igzip.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ def test_igzip_reader_read_zero():
6262
assert test.read(0) == b""
6363

6464

65+
def test_igzipfile_read_truncated():
66+
# Chop of trailer (8 bytes) and part of DEFLATE stream
67+
data = io.BytesIO(COMPRESSED_DATA[:-10])
68+
test = igzip.GzipFile(fileobj=data, mode="rb")
69+
with pytest.raises(EOFError) as error:
70+
test.read()
71+
error.match("Compressed file ended before the end-of-stream marker was "
72+
"reached")
73+
74+
6575
@pytest.mark.parametrize("level", range(1, 10))
6676
def test_decompress_stdin_stdout(capsysbinary, level):
6777
"""Test if the command line can decompress data that has been compressed

0 commit comments

Comments
 (0)