Skip to content

Commit 0e62277

Browse files
authored
Merge pull request #113 from pycompression/onehundredcoverage
Increase test coverage
2 parents e4a04d5 + 1718ccc commit 0e62277

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_igzip.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,28 @@ def test_write_readonly_file():
5050
error.match(r"write\(\) on read-only IGzipFile object")
5151

5252

53+
def test_igzip_reader_readall():
54+
data = io.BytesIO(COMPRESSED_DATA)
55+
test = igzip._IGzipReader(data)
56+
assert test.read(-1) == DATA
57+
58+
59+
def test_igzip_reader_read_zero():
60+
data = io.BytesIO(COMPRESSED_DATA)
61+
test = igzip._IGzipReader(data)
62+
assert test.read(0) == b""
63+
64+
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+
5375
@pytest.mark.parametrize("level", range(1, 10))
5476
def test_decompress_stdin_stdout(capsysbinary, level):
5577
"""Test if the command line can decompress data that has been compressed

0 commit comments

Comments
 (0)