1515import re
1616import shutil
1717import struct
18- import subprocess
1918import sys
2019import tempfile
2120import zlib
2928DATA = b'This is a simple test with igzip'
3029COMPRESSED_DATA = gzip .compress (DATA )
3130TEST_FILE = str ((Path (__file__ ).parent / "data" / "test.fastq.gz" ))
32- PYPY = sys .implementation .name == "pypy"
33-
34-
35- def run_isal_igzip (* args , stdin = None ):
36- """Calling isal.igzip externally seems to solve some issues on PyPy where
37- files would not be written properly when igzip.main() was called. This is
38- probably due to some out of order execution that PyPy tries to pull.
39- Running the process externally is detrimental to the coverage report,
40- so this is only done for PyPy."""
41- process = subprocess .Popen (["python" , "-m" , "isal.igzip" , * args ],
42- stdout = subprocess .PIPE ,
43- stderr = subprocess .PIPE ,
44- stdin = subprocess .PIPE )
45-
46- return process .communicate (stdin )
4731
4832
4933def test_wrong_compresslevel_igzipfile ():
@@ -128,12 +112,9 @@ def test_decompress_infile_outfile(tmp_path, capsysbinary):
128112def test_compress_infile_outfile (tmp_path , capsysbinary ):
129113 test_file = tmp_path / "test"
130114 test_file .write_bytes (DATA )
131- if PYPY :
132- out , err = run_isal_igzip (str (test_file ))
133- else :
134- sys .argv = ['' , str (test_file )]
135- igzip .main ()
136- out , err = capsysbinary .readouterr ()
115+ sys .argv = ['' , str (test_file )]
116+ igzip .main ()
117+ out , err = capsysbinary .readouterr ()
137118 out_file = test_file .with_suffix (".gz" )
138119 assert err == b''
139120 assert out == b''
@@ -196,12 +177,9 @@ def test_compress_infile_out_file(tmp_path, capsysbinary):
196177 test .write_bytes (DATA )
197178 out_file = tmp_path / "compressed.gz"
198179 args = ['-o' , str (out_file ), str (test )]
199- if PYPY :
200- out , err = run_isal_igzip (* args )
201- else :
202- sys .argv = ['' , * args ]
203- igzip .main ()
204- out , err = capsysbinary .readouterr ()
180+ sys .argv = ['' , * args ]
181+ igzip .main ()
182+ out , err = capsysbinary .readouterr ()
205183 assert gzip .decompress (out_file .read_bytes ()) == DATA
206184 assert err == b''
207185 assert out == b''
@@ -213,12 +191,9 @@ def test_compress_infile_out_file_force(tmp_path, capsysbinary):
213191 out_file = tmp_path / "compressed.gz"
214192 out_file .touch ()
215193 args = ['-f' , '-o' , str (out_file ), str (test )]
216- if PYPY :
217- out , err = run_isal_igzip (* args )
218- else :
219- sys .argv = ['' , * args ]
220- igzip .main ()
221- out , err = capsysbinary .readouterr ()
194+ sys .argv = ['' , * args ]
195+ igzip .main ()
196+ out , err = capsysbinary .readouterr ()
222197 assert gzip .decompress (out_file .read_bytes ()) == DATA
223198 assert err == b''
224199 assert out == b''
@@ -261,14 +236,11 @@ def test_compress_infile_out_file_inmplicit_name_prompt_accept(
261236 test .write_bytes (DATA )
262237 out_file = tmp_path / "test.gz"
263238 out_file .touch ()
264- if PYPY :
265- out , err = run_isal_igzip (str (test ), stdin = b"y\n " )
266- else :
267- sys .argv = ['' , str (test )]
268- mock_stdin = io .BytesIO (b"y" )
269- sys .stdin = io .TextIOWrapper (mock_stdin )
270- igzip .main ()
271- out , err = capsysbinary .readouterr ()
239+ sys .argv = ['' , str (test )]
240+ mock_stdin = io .BytesIO (b"y" )
241+ sys .stdin = io .TextIOWrapper (mock_stdin )
242+ igzip .main ()
243+ out , err = capsysbinary .readouterr ()
272244 assert b"already exists; do you wish to overwrite" in out
273245 assert err == b""
274246 assert gzip .decompress (out_file .read_bytes ()) == DATA
@@ -278,13 +250,9 @@ def test_compress_infile_out_file_no_name(tmp_path, capsysbinary):
278250 test = tmp_path / "test"
279251 test .write_bytes (DATA )
280252 out_file = tmp_path / "compressed.gz"
281- args = ['-n' , '-o' , str (out_file ), str (test )]
282- if PYPY :
283- out , err = run_isal_igzip (* args )
284- else :
285- sys .argv = ['' , '-n' , '-o' , str (out_file ), str (test )]
286- igzip .main ()
287- out , err = capsysbinary .readouterr ()
253+ sys .argv = ['' , '-n' , '-o' , str (out_file ), str (test )]
254+ igzip .main ()
255+ out , err = capsysbinary .readouterr ()
288256 output = out_file .read_bytes ()
289257 assert gzip .decompress (output ) == DATA
290258 assert err == b''
0 commit comments