Skip to content

Commit 03e98dc

Browse files
authored
Merge pull request #47 from pycompression/morecoverage
Add a few extra tests for improved coverage
2 parents 9ea5911 + 13daae3 commit 03e98dc

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

codecov.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
comment: off
21
coverage:
32
status:
43
project:

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

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ passenv=
99
PYTHON_ISAL_LINK_DYNAMIC
1010
commands =
1111
# Create HTML coverage report for humans and xml coverage report for external services.
12-
coverage run --source={envsitepackagesdir}/isal -m py.test tests
12+
coverage run --source=isal -m py.test tests
1313
coverage html
1414
coverage xml
1515

@@ -24,7 +24,7 @@ setenv=
2424
CYTHON_COVERAGE=true
2525
commands =
2626
# Create HTML coverage report for humans and xml coverage report for external services.
27-
coverage run --source={envsitepackagesdir}/isal -m py.test tests
27+
coverage run --source=isal -m py.test tests
2828
coverage html
2929
coverage xml
3030

0 commit comments

Comments
 (0)