Skip to content
Snippets Groups Projects
Commit 8e21227d authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

TEST: test fslmaths LOAD behaviour

parent 7d5e6305
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,10 @@ def mockFSLDIR(**kwargs): ...@@ -50,7 +50,10 @@ def mockFSLDIR(**kwargs):
if not op.isdir(subdir): if not op.isdir(subdir):
os.makedirs(subdir) os.makedirs(subdir)
for fname in files: for fname in files:
touch(op.join(subdir, fname)) fname = op.join(subdir, fname)
touch(fname)
if subdir == bindir:
os.chmod(fname, 0o755)
fslplatform.fsldir = fsldir fslplatform.fsldir = fsldir
fslplatform.fsldevdir = None fslplatform.fsldevdir = None
......
...@@ -5,14 +5,19 @@ ...@@ -5,14 +5,19 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com> # Author: Paul McCarthy <pauldmccarthy@gmail.com>
# #
import os
import os.path as op import os.path as op
import itertools as it import itertools as it
import textwrap as tw
import numpy as np
import fsl.wrappers as fw import fsl.wrappers as fw
import fsl.utils.assertions as asrt import fsl.utils.assertions as asrt
import fsl.utils.run as run import fsl.utils.run as run
from fsl.utils.tempdir import tempdir
from . import mockFSLDIR from . import mockFSLDIR, make_random_image
def checkResult(cmd, base, args, stripdir=None): def checkResult(cmd, base, args, stripdir=None):
...@@ -272,7 +277,23 @@ def test_fslmaths(): ...@@ -272,7 +277,23 @@ def test_fslmaths():
assert result.output[0] == expected assert result.output[0] == expected
# TODO test LOAD output # test LOAD output
with tempdir() as td, mockFSLDIR(bin=('fslmaths',)) as fsldir:
expect = make_random_image(op.join(td, 'output.nii.gz'))
with open(op.join(fsldir, 'bin', 'fslmaths'), 'wt') as f:
f.write(tw.dedent("""
#!/usr/bin/env python
import sys
import shutil
shutil.copy('{}', sys.argv[2])
""".format(op.join(td, 'output.nii.gz'))).strip())
os.chmod(op.join(fsldir, 'bin', 'fslmaths'), 0o755)
got = fw.fslmaths('input').run()
assert np.all(expect.dataobj[:] == got.dataobj[:])
got = fw.fslmaths('input').run(fw.LOAD)
assert np.all(expect.dataobj[:] == got.dataobj[:])
def test_fast(): def test_fast():
with asrt.disabled(), run.dryrun(), mockFSLDIR(bin=('fast',)) as fsldir: with asrt.disabled(), run.dryrun(), mockFSLDIR(bin=('fast',)) as fsldir:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment