Skip to content

Commit 7bb933c

Browse files
author
Adam Robbins-Pianka
committed
Simplify use of contexts in tests
1 parent da407f6 commit 7bb933c

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

qiita_ware/test/test_demux.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,9 @@ def test_to_hdf5(self):
246246
with tempfile.NamedTemporaryFile('r+', suffix='.fna',
247247
delete=False) as f:
248248
f.write(seqdata)
249-
f.flush()
250-
f.close()
251249

252-
to_hdf5(f.name, self.hdf5_file)
253-
self.to_remove.append(f.name)
250+
self.to_remove.append(f.name)
251+
to_hdf5(f.name, self.hdf5_file)
254252

255253
npt.assert_equal(self.hdf5_file['a/sequence'][:], np.array(["x", "xy",
256254
"xyz"]))
@@ -283,14 +281,13 @@ def test_to_ascii(self):
283281
with tempfile.NamedTemporaryFile('r+', suffix='.fq',
284282
delete=False) as f:
285283
f.write(fqdata)
286-
f.flush()
287-
f.close()
288-
to_hdf5(f.name, self.hdf5_file)
289-
self.to_remove.append(f.name)
290284

291285
exp = [(b"@a_0 orig_bc=abc new_bc=abc bc_diffs=0\nxyz\n+\nABC\n"),
292286
(b"@b_0 orig_bc=abw new_bc=wbc bc_diffs=4\nqwe\n+\nDFG\n"),
293287
(b"@b_1 orig_bc=abw new_bc=wbc bc_diffs=4\nqwe\n+\nDEF\n")]
288+
self.to_remove.append(f.name)
289+
to_hdf5(f.name, self.hdf5_file)
290+
294291

295292
obs = list(to_ascii(self.hdf5_file, samples=['a', 'b']))
296293
self.assertEqual(obs, exp)
@@ -299,10 +296,9 @@ def test_to_per_sample_ascii(self):
299296
with tempfile.NamedTemporaryFile('r+', suffix='.fq',
300297
delete=False) as f:
301298
f.write(fqdata)
302-
f.flush()
303-
f.close()
304-
to_hdf5(f.name, self.hdf5_file)
305-
self.to_remove.append(f.name)
299+
300+
self.to_remove.append(f.name)
301+
to_hdf5(f.name, self.hdf5_file)
306302

307303
exp = [('a', [(b"@a_0 orig_bc=abc new_bc=abc bc_diffs=0\nxyz\n+\n"
308304
"ABC\n")]),

0 commit comments

Comments
 (0)