Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
fslpy
Commits
d53aae7c
Commit
d53aae7c
authored
Aug 20, 2021
by
Paul McCarthy
🚵
Browse files
TEST: Adjust unit tests r.e. fslsub/run changes
parent
46dd22ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests/__init__.py
View file @
d53aae7c
...
...
@@ -69,7 +69,7 @@ def touch(fname):
pass
class
CaptureStdout
(
object
)
:
class
CaptureStdout
:
"""Context manager which captures stdout and stderr. """
def
__init__
(
self
):
...
...
tests/test_run.py
View file @
d53aae7c
...
...
@@ -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
]
...
...
tests/test_wrappers/test_wrapperutils.py
View file @
d53aae7c
...
...
@@ -27,7 +27,7 @@ import fsl.wrappers.wrapperutils as wutils
from
..
import
mockFSLDIR
,
cleardir
,
checkdir
,
testdir
,
touch
from
..test_run
import
mock_sub
mit
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_sub
mit
),
\
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_sub
mit
):
mock
.
patch
(
'fsl.
wrappers.fsl_sub
'
,
mock_
fsl_
sub
):
test_file
=
op
.
join
(
fsldir
,
'bin'
,
'test_script'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment