Skip to content

Commit

Permalink
close statement after all test
Browse files Browse the repository at this point in the history
  • Loading branch information
frheault committed Oct 10, 2023
1 parent 2bb608e commit 7fa6cc0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scripts/tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@


def test_help_option_convert_dsi(script_runner):
ret = script_runner.run('tff_convert_dsi_studio.py', '--help')
ret = script_runner.run(['tff_convert_dsi_studio.py', '--help'])
assert ret.success


def test_help_option_convert(script_runner):
ret = script_runner.run('tff_convert_tractogram.py', '--help')
ret = script_runner.run(['tff_convert_tractogram.py', '--help'])
assert ret.success


def test_help_option_generate_trx_from_scratch(script_runner):
ret = script_runner.run('tff_generate_trx_from_scratch.py', '--help')
ret = script_runner.run(['tff_generate_trx_from_scratch.py', '--help'])
assert ret.success


Expand Down Expand Up @@ -211,6 +211,7 @@ def test_execution_generate_trx_from_scratch():
exp_trx.close()
gen_trx.close()


@pytest.mark.skipif(not dipy_available,
reason='Dipy is not installed.')
def test_execution_concatenate_validate_trx():
Expand Down
6 changes: 6 additions & 0 deletions trx/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def test_load_vox(path):
sft.to_vox()

assert_allclose(sft.streamlines._data, coord, rtol=1e-04, atol=1e-06)
if isinstance(obj, TrxFile):
obj.close()


@pytest.mark.parametrize("path", [("gs.trx"), ("gs.trk"), ("gs.tck"),
Expand All @@ -53,6 +55,8 @@ def test_load_voxmm(path):
sft.to_voxmm()

assert_allclose(sft.streamlines._data, coord, rtol=1e-04, atol=1e-06)
if isinstance(obj, TrxFile):
obj.close()


@pytest.mark.parametrize("path", [("gs.trk"), ("gs.trx"), ("gs_fldr.trx")])
Expand All @@ -68,6 +72,8 @@ def test_multi_load_save_rasmm(path):
obj = load(path, os.path.join(dir, 'gs.nii'))
for _ in range(100):
save(obj, out_path)
if isinstance(obj, TrxFile):
obj.close()
obj = load(out_path, os.path.join(dir, 'gs.nii'))

assert_allclose(obj.streamlines._data, coord, rtol=1e-04, atol=1e-06)
16 changes: 16 additions & 0 deletions trx/tests/test_memmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ def test_concatenate(path):
trx1 = tmm.load(path)
trx2 = tmm.load(path)
concat = tmm.concatenate([trx1, trx2])

assert len(concat) == 2 * len(trx2)
trx1.close()
trx2.close()
concat.close()


@pytest.mark.parametrize("path", [("small.trx")])
Expand All @@ -200,7 +204,10 @@ def test_resize(path):

tmm.concatenate([concat, trx1], preallocation=True, delete_groups=True)
concat.resize()

assert len(concat) == len(trx1)
trx1.close()
concat.close()


@pytest.mark.parametrize(
Expand All @@ -219,7 +226,10 @@ def test_append(path, buffer):
concat.append(trx1, extra_buffer=buffer)
if buffer > 0:
concat.resize()

assert len(concat) == len(trx1)
trx1.close()
concat.close()


@pytest.mark.parametrize("path, buffer", [("small.trx", 10000)])
Expand All @@ -233,7 +243,10 @@ def test_append_StatefulTractogram(path, buffer):
concat.append(obj, extra_buffer=buffer)
if buffer > 0:
concat.resize()

assert len(concat) == len(obj)
trx.close()
concat.close()


@pytest.mark.parametrize("path, buffer", [("small.trx", 10000)])
Expand All @@ -246,7 +259,10 @@ def test_append_Tractogram(path, buffer):
concat.append(obj, extra_buffer=buffer)
if buffer > 0:
concat.resize()

assert len(concat) == len(obj)
trx.close()
concat.close()


@pytest.mark.parametrize("path, size, buffer", [("small.trx", 50, 10000),
Expand Down

0 comments on commit 7fa6cc0

Please sign in to comment.