Skip to content

Commit e03e2b8

Browse files
committed
Add a few extra tests for improved coverage
1 parent 9ea5911 commit e03e2b8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_igzip.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@
2424

2525
import gzip
2626
import io
27+
import os
28+
import shutil
2729
import sys
30+
import tempfile
31+
from pathlib import Path
2832

2933
from isal import igzip
3034

3135
import pytest
3236

3337
DATA = b'This is a simple test with igzip'
3438
COMPRESSED_DATA = gzip.compress(DATA)
39+
TEST_FILE = str((Path(__file__).parent / "data" / "test.fastq.gz"))
3540

3641

3742
def test_wrong_compresslevel_igzipfile():
@@ -40,6 +45,20 @@ def test_wrong_compresslevel_igzipfile():
4045
error.match("Compression level should be between 0 and 3")
4146

4247

48+
def test_repr():
49+
tempdir = tempfile.mkdtemp()
50+
with igzip.IGzipFile(os.path.join(tempdir, "test.gz"), "wb") as test:
51+
assert "<igzip _io.BufferedWriter name='" in repr(test)
52+
shutil.rmtree(tempdir)
53+
54+
55+
def test_write_readonly_file():
56+
with igzip.IGzipFile(TEST_FILE, "rb") as test:
57+
with pytest.raises(OSError) as error:
58+
test.write(b"bla")
59+
error.match(r"write\(\) on read-only IGzipFile object")
60+
61+
4362
@pytest.mark.parametrize("level", range(1, 10))
4463
def test_decompress_stdin_stdout(capsysbinary, level):
4564
"""Test if the command line can decompress data that has been compressed

0 commit comments

Comments
 (0)