Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD 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
FSL
fslpy
Commits
1c279f81
Commit
1c279f81
authored
4 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Unit tests for imtest
parent
3099f2fe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_scripts/test_imtest.py
+83
-0
83 additions, 0 deletions
tests/test_scripts/test_imtest.py
with
83 additions
and
0 deletions
tests/test_scripts/test_imtest.py
0 → 100644
+
83
−
0
View file @
1c279f81
#!/usr/bin/env python
#
# test_imtest.py -
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import
os
import
os.path
as
op
import
fsl.utils.path
as
fslpath
from
fsl.utils.tempdir
import
tempdir
import
fsl.scripts.imtest
as
imtest
from
tests
import
CaptureStdout
,
touch
def
test_wrongargs
():
cap
=
CaptureStdout
()
with
cap
:
assert
imtest
.
main
([])
==
0
assert
cap
.
stdout
.
strip
()
==
'
0
'
def
test_imtest
():
# (files, input, expected)
tests
=
[
(
'
a.nii
'
,
'
a
'
,
'
1
'
),
(
'
a.nii
'
,
'
a.nii
'
,
'
1
'
),
(
'
a.nii
'
,
'
a.nii.gz
'
,
'
1
'
),
# imtest is suffix-agnostic
(
'
a.img a.hdr
'
,
'
a
'
,
'
1
'
),
(
'
a.img a.hdr
'
,
'
a.img
'
,
'
1
'
),
(
'
a.img a.hdr
'
,
'
a.hdr
'
,
'
1
'
),
(
'
a.img
'
,
'
a
'
,
'
0
'
),
(
'
a.img
'
,
'
a.img
'
,
'
0
'
),
(
'
a.img
'
,
'
a.hdr
'
,
'
0
'
),
(
'
a.hdr
'
,
'
a
'
,
'
0
'
),
(
'
a.hdr
'
,
'
a.img
'
,
'
0
'
),
(
'
a.hdr
'
,
'
a.hdr
'
,
'
0
'
),
(
'
dir/a.nii
'
,
'
dir/a
'
,
'
1
'
),
(
'
dir/a.img dir/a.hdr
'
,
'
dir/a
'
,
'
1
'
),
]
for
files
,
input
,
expected
in
tests
:
with
tempdir
():
for
f
in
files
.
split
():
dirname
=
op
.
dirname
(
f
)
if
dirname
!=
''
:
os
.
makedirs
(
dirname
,
exist_ok
=
True
)
touch
(
f
)
cap
=
CaptureStdout
()
with
cap
:
assert
imtest
.
main
([
input
])
==
0
assert
cap
.
stdout
.
strip
()
==
expected
# test that sym-links are
# followed correctly
with
tempdir
():
touch
(
'
image.nii.gz
'
)
os
.
symlink
(
'
image.nii.gz
'
,
'
link.nii.gz
'
)
cap
=
CaptureStdout
()
with
cap
:
assert
imtest
.
main
([
'
link
'
])
==
0
assert
cap
.
stdout
.
strip
()
==
'
1
'
# sym-links in sub-directories
# (old imtest would not work
# in this scenario)
with
tempdir
():
os
.
mkdir
(
'
subdir
'
)
impath
=
op
.
join
(
'
subdir
'
,
'
image.nii.gz
'
)
lnpath
=
op
.
join
(
'
subdir
'
,
'
link.nii.gz
'
)
touch
(
impath
)
os
.
symlink
(
'
image.nii.gz
'
,
lnpath
)
cap
=
CaptureStdout
()
with
cap
:
assert
imtest
.
main
([
lnpath
])
==
0
assert
cap
.
stdout
.
strip
()
==
'
1
'
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