File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1
- comment : off
2
1
coverage :
3
2
status :
4
3
project :
Original file line number Diff line number Diff line change 24
24
25
25
import gzip
26
26
import io
27
+ import os
28
+ import shutil
27
29
import sys
30
+ import tempfile
31
+ from pathlib import Path
28
32
29
33
from isal import igzip
30
34
31
35
import pytest
32
36
33
37
DATA = b'This is a simple test with igzip'
34
38
COMPRESSED_DATA = gzip .compress (DATA )
39
+ TEST_FILE = str ((Path (__file__ ).parent / "data" / "test.fastq.gz" ))
35
40
36
41
37
42
def test_wrong_compresslevel_igzipfile ():
@@ -40,6 +45,20 @@ def test_wrong_compresslevel_igzipfile():
40
45
error .match ("Compression level should be between 0 and 3" )
41
46
42
47
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
+
43
62
@pytest .mark .parametrize ("level" , range (1 , 10 ))
44
63
def test_decompress_stdin_stdout (capsysbinary , level ):
45
64
"""Test if the command line can decompress data that has been compressed
Original file line number Diff line number Diff line change 9
9
PYTHON_ISAL_LINK_DYNAMIC
10
10
commands =
11
11
# 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
13
13
coverage html
14
14
coverage xml
15
15
@@ -24,7 +24,7 @@ setenv=
24
24
CYTHON_COVERAGE =true
25
25
commands =
26
26
# 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
28
28
coverage html
29
29
coverage xml
30
30
You can’t perform that action at this time.
0 commit comments