Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
3738b75f
Commit
3738b75f
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Unit test for fsldir/fsldevdir/fsl_prefix
parent
f7bf82cb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_run.py
+39
-9
39 additions, 9 deletions
tests/test_run.py
with
39 additions
and
9 deletions
tests/test_run.py
+
39
−
9
View file @
3738b75f
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
import
os.path
as
op
import
os.path
as
op
import
os
import
os
import
shutil
import
textwrap
import
textwrap
# python 3
# python 3
...
@@ -161,11 +162,13 @@ def test_runfsl():
...
@@ -161,11 +162,13 @@ def test_runfsl():
test_script
=
textwrap
.
dedent
(
"""
test_script
=
textwrap
.
dedent
(
"""
#!/bin/bash
#!/bin/bash
echo
$@
echo
{}
exit 0
exit 0
"""
).
strip
()
"""
).
strip
()
old_fsldir
=
fslplatform
.
fsldir
old_fsldir
=
fslplatform
.
fsldir
old_fsldevdir
=
fslplatform
.
fsldevdir
try
:
try
:
with
tempdir
.
tempdir
():
with
tempdir
.
tempdir
():
...
@@ -173,24 +176,51 @@ def test_runfsl():
...
@@ -173,24 +176,51 @@ def test_runfsl():
make_random_image
(
'
image.nii.gz
'
)
make_random_image
(
'
image.nii.gz
'
)
# no FSLDIR - should error
# no FSLDIR - should error
fslplatform
.
fsldir
=
None
fslplatform
.
fsldir
=
None
fslplatform
.
fsldevdir
=
None
with
pytest
.
raises
(
run
.
FSLNotPresent
):
with
pytest
.
raises
(
run
.
FSLNotPresent
):
run
.
runfsl
(
'
fslhd
image
'
)
run
.
runfsl
(
'
fslhd
'
)
# FSLDIR/bin exists - should be good
# FSLDIR/bin exists - should be good
fsldir
=
op
.
abspath
(
'
./fsl
'
)
fsldir
=
op
.
abspath
(
'
./fsl
'
)
fslhd
=
op
.
join
(
fsldir
,
'
bin
'
,
'
fslhd
'
)
fslhd
=
op
.
join
(
fsldir
,
'
bin
'
,
'
fslhd
'
)
os
.
makedirs
(
op
.
join
(
fsldir
,
'
bin
'
))
os
.
makedirs
(
op
.
join
(
fsldir
,
'
bin
'
))
with
open
(
fslhd
,
'
wt
'
)
as
f
:
with
open
(
fslhd
,
'
wt
'
)
as
f
:
f
.
write
(
test_script
)
f
.
write
(
test_script
.
format
(
'
fsldir
'
)
)
os
.
chmod
(
fslhd
,
0o777
)
os
.
chmod
(
fslhd
,
0o777
)
fslplatform
.
fsldir
=
fsldir
fslplatform
.
fsldir
=
fsldir
path
=
op
.
pathsep
.
join
((
fsldir
,
os
.
environ
[
'
PATH
'
]))
assert
run
.
runfsl
(
'
fslhd
'
).
strip
()
==
'
fsldir
'
with
mock
.
patch
.
dict
(
os
.
environ
,
{
'
PATH
'
:
path
}):
assert
run
.
runfsl
(
'
fslhd image
'
).
strip
()
==
'
image
'
# FSLDEVDIR should take precedence
fsldevdir
=
'
./fsldev
'
fslhd
=
op
.
join
(
fsldevdir
,
'
bin
'
,
'
fslhd
'
)
shutil
.
copytree
(
fsldir
,
fsldevdir
)
with
open
(
fslhd
,
'
wt
'
)
as
f
:
f
.
write
(
test_script
.
format
(
'
fsldevdir
'
))
fslplatform
.
fsldevdir
=
fsldevdir
fslplatform
.
fsldir
=
None
assert
run
.
runfsl
(
'
fslhd
'
).
strip
()
==
'
fsldevdir
'
# FSL_PREFIX should override all
override
=
'
./override
'
fslhd
=
op
.
join
(
override
,
'
fslhd
'
)
os
.
makedirs
(
override
)
with
open
(
fslhd
,
'
wt
'
)
as
f
:
f
.
write
(
test_script
.
format
(
'
override
'
))
os
.
chmod
(
fslhd
,
0o777
)
fslplatform
.
fsldir
=
None
fslplatform
.
fsldevdir
=
None
run
.
FSL_PREFIX
=
override
assert
run
.
runfsl
(
'
fslhd
'
).
strip
()
==
'
override
'
finally
:
finally
:
fslplatform
.
fsldir
=
old_fsldir
fslplatform
.
fsldir
=
old_fsldir
fslplatform
.
fsldevdir
=
old_fsldevdir
run
.
FSL_PREFIX
=
None
def
mock_submit
(
cmd
,
**
kwargs
):
def
mock_submit
(
cmd
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment