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
21coverage :
32 status :
43 project :
Original file line number Diff line number Diff line change 2424
2525import gzip
2626import io
27+ import os
28+ import shutil
2729import sys
30+ import tempfile
31+ from pathlib import Path
2832
2933from isal import igzip
3034
3135import pytest
3236
3337DATA = b'This is a simple test with igzip'
3438COMPRESSED_DATA = gzip .compress (DATA )
39+ TEST_FILE = str ((Path (__file__ ).parent / "data" / "test.fastq.gz" ))
3540
3641
3742def 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 ))
4463def test_decompress_stdin_stdout (capsysbinary , level ):
4564 """Test if the command line can decompress data that has been compressed
Original file line number Diff line number Diff line change 99 PYTHON_ISAL_LINK_DYNAMIC
1010commands =
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
2525commands =
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
You can’t perform that action at this time.
0 commit comments