29
29
DATA = b'This is a simple test with igzip'
30
30
COMPRESSED_DATA = gzip .compress (DATA )
31
31
TEST_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 )
47
32
48
33
49
34
def test_wrong_compresslevel_igzipfile ():
@@ -128,12 +113,9 @@ def test_decompress_infile_outfile(tmp_path, capsysbinary):
128
113
def test_compress_infile_outfile (tmp_path , capsysbinary ):
129
114
test_file = tmp_path / "test"
130
115
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 ()
116
+ sys .argv = ['' , str (test_file )]
117
+ igzip .main ()
118
+ out , err = capsysbinary .readouterr ()
137
119
out_file = test_file .with_suffix (".gz" )
138
120
assert err == b''
139
121
assert out == b''
@@ -196,12 +178,9 @@ def test_compress_infile_out_file(tmp_path, capsysbinary):
196
178
test .write_bytes (DATA )
197
179
out_file = tmp_path / "compressed.gz"
198
180
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 ()
181
+ sys .argv = ['' , * args ]
182
+ igzip .main ()
183
+ out , err = capsysbinary .readouterr ()
205
184
assert gzip .decompress (out_file .read_bytes ()) == DATA
206
185
assert err == b''
207
186
assert out == b''
@@ -213,12 +192,9 @@ def test_compress_infile_out_file_force(tmp_path, capsysbinary):
213
192
out_file = tmp_path / "compressed.gz"
214
193
out_file .touch ()
215
194
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 ()
195
+ sys .argv = ['' , * args ]
196
+ igzip .main ()
197
+ out , err = capsysbinary .readouterr ()
222
198
assert gzip .decompress (out_file .read_bytes ()) == DATA
223
199
assert err == b''
224
200
assert out == b''
@@ -261,14 +237,11 @@ def test_compress_infile_out_file_inmplicit_name_prompt_accept(
261
237
test .write_bytes (DATA )
262
238
out_file = tmp_path / "test.gz"
263
239
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 ()
240
+ sys .argv = ['' , str (test )]
241
+ mock_stdin = io .BytesIO (b"y" )
242
+ sys .stdin = io .TextIOWrapper (mock_stdin )
243
+ igzip .main ()
244
+ out , err = capsysbinary .readouterr ()
272
245
assert b"already exists; do you wish to overwrite" in out
273
246
assert err == b""
274
247
assert gzip .decompress (out_file .read_bytes ()) == DATA
@@ -279,12 +252,9 @@ def test_compress_infile_out_file_no_name(tmp_path, capsysbinary):
279
252
test .write_bytes (DATA )
280
253
out_file = tmp_path / "compressed.gz"
281
254
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 ()
255
+ sys .argv = ['' , '-n' , '-o' , str (out_file ), str (test )]
256
+ igzip .main ()
257
+ out , err = capsysbinary .readouterr ()
288
258
output = out_file .read_bytes ()
289
259
assert gzip .decompress (output ) == DATA
290
260
assert err == b''
0 commit comments