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

TEST: unit test for fsl_sub

parent e0ed39cf
No related branches found
No related tags found
No related merge requests found
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
# 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 textwrap as tw
import os
import shlex
import numpy as np import numpy as np
...@@ -21,8 +22,10 @@ from .. import mockFSLDIR, make_random_image ...@@ -21,8 +22,10 @@ from .. import mockFSLDIR, make_random_image
def checkResult(cmd, base, args, stripdir=None): def checkResult(cmd, base, args, stripdir=None):
"""We can't control the order in which command line args are generated, """Check that the generate dcommand matches the expected command.
so we need to test all possible orderings.
Pre python 3.7, we couldn't control the order in which command
line args were generated, so we needed to test all possible orderings.
:arg cmd: Generated command :arg cmd: Generated command
:arg base: Beginning of expected command :arg base: Beginning of expected command
...@@ -409,3 +412,15 @@ def test_fsl_prepare_fieldmap(): ...@@ -409,3 +412,15 @@ def test_fsl_prepare_fieldmap():
nocheck=True) nocheck=True)
expected = (fpf, ('SIEMENS', 'ph', 'mag', 'out', '2.46', '--nocheck')) expected = (fpf, ('SIEMENS', 'ph', 'mag', 'out', '2.46', '--nocheck'))
assert checkResult(result.stdout[0], *expected) assert checkResult(result.stdout[0], *expected)
def test_fsl_sub():
with run.dryrun(), mockFSLDIR(bin=('fsl_sub',)) as fsldir:
expected = [op.join(fsldir, 'bin', 'fsl_sub'),
'--jobhold', '123',
'--queue', 'long.q',
'some_command', '--some_arg']
result = fw.fsl_sub(
'some_command', '--some_arg', jobhold='123', queue='long.q')
assert shlex.split(result[0]) == expected
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