Commit d53aae7c authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: Adjust unit tests r.e. fslsub/run changes

parent 46dd22ee
......@@ -69,7 +69,7 @@ def touch(fname):
pass
class CaptureStdout(object):
class CaptureStdout:
"""Context manager which captures stdout and stderr. """
def __init__(self):
......
......@@ -119,12 +119,23 @@ def test_run_tee():
capture = CaptureStdout()
# default behaviour is for tee=True
with capture:
stdout = run.run('./script.sh 1 2 3', log={'tee' : True})
stdout = run.run('./script.sh 1 2 3')
assert stdout == expstdout
assert capture.stdout == expstdout
with capture.reset():
stdout = run.run('./script.sh 1 2 3', log={'tee' : True})
assert stdout == expstdout
assert capture.stdout == expstdout
# disable forwarding
with capture.reset():
stdout = run.run('./script.sh 1 2 3', log={'tee' : False})
assert stdout == expstdout
assert capture.stdout == ''
with capture.reset():
stdout, stderr = run.run('./script.sh 1 2 3', stderr=True,
log={'tee' : True})
......@@ -268,9 +279,9 @@ def test_runfsl():
run.FSL_PREFIX = None
def mock_fsl_sub(cmd, **kwargs):
if isinstance(cmd, str):
name = cmd.split()[0]
def mock_fsl_sub(*cmd, **kwargs):
if len(cmd) == 1 and isinstance(cmd[0], str):
name = cmd[0].split()[0]
else:
name = cmd[0]
......
......@@ -27,7 +27,7 @@ import fsl.wrappers.wrapperutils as wutils
from .. import mockFSLDIR, cleardir, checkdir, testdir, touch
from ..test_run import mock_submit
from ..test_run import mock_fsl_sub
def test_applyArgStyle():
......@@ -789,7 +789,7 @@ def test_cmdwrapper_submit():
newpath = op.pathsep.join(('.', os.environ['PATH']))
with tempdir.tempdir(), \
mock.patch('fsl.utils.fslsub.submit', mock_submit), \
mock.patch('fsl.wrappers.fsl_sub', mock_fsl_sub), \
mock.patch.dict(os.environ, {'PATH' : newpath}):
with open('test_script', 'wt') as f:
......@@ -812,7 +812,7 @@ def test_fslwrapper_submit():
test_func = wutils.fslwrapper(_test_script_func)
with mockFSLDIR() as fsldir, \
mock.patch('fsl.utils.fslsub.submit', mock_submit):
mock.patch('fsl.wrappers.fsl_sub', mock_fsl_sub):
test_file = op.join(fsldir, 'bin', 'test_script')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment