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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Evan Edmond
fslpy
Commits
0864bae2
Commit
0864bae2
authored
4 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Had two imglob test scripts
parent
a8e121e9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_imglob.py
+0
-87
0 additions, 87 deletions
tests/test_imglob.py
tests/test_scripts/test_imglob.py
+78
-2
78 additions, 2 deletions
tests/test_scripts/test_imglob.py
with
78 additions
and
89 deletions
tests/test_imglob.py
deleted
100644 → 0
+
0
−
87
View file @
a8e121e9
#!/usr/bin/env python
#
# test_imglob.py -
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import
pytest
import
fsl.scripts.imglob
as
imglob
from
.
import
testdir
def
test_imglob_shouldPass
():
# (files to create, paths, output, expected)
tests
=
[
# normal usage, one file
(
'
file.hdr file.img
'
,
'
file
'
,
None
,
'
file
'
),
(
'
file.hdr file.img
'
,
'
file
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr file.img
'
,
'
file
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr file.img
'
,
'
file
'
,
'
all
'
,
'
file.hdr file.img
'
),
# incomplete file pair
(
'
file.hdr
'
,
'
file
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr
'
,
'
file.hdr
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr
'
,
'
file.img
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr
'
,
'
file
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file.hdr
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file.img
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file
'
,
'
all
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file.hdr
'
,
'
all
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file.img
'
,
'
all
'
,
'
file.hdr
'
),
# same file specified multiple times
(
'
file.hdr file.img
'
,
'
file file
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr file.img
'
,
'
file file.img
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr file.img
'
,
'
file file.img file.hdr
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr file.img
'
,
'
file file
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr file.img
'
,
'
file file.img
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr file.img
'
,
'
file file.img file.hdr
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr file.img
'
,
'
file file
'
,
'
all
'
,
'
file.hdr file.img
'
),
(
'
file.hdr file.img
'
,
'
file file.img
'
,
'
all
'
,
'
file.hdr file.img
'
),
(
'
file.hdr file.img
'
,
'
file file.img file.hdr
'
,
'
all
'
,
'
file.hdr file.img
'
),
# multiple files same prefix
(
'
file.hdr file.img file.nii
'
,
'
file
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr file.img file.nii
'
,
'
file
'
,
'
primary
'
,
'
file.hdr file.nii
'
),
(
'
file.hdr file.img file.nii
'
,
'
file
'
,
'
all
'
,
'
file.hdr file.img file.nii
'
),
# multiple files
(
'
file1.hdr file1.img file2.nii
'
,
'
file1
'
,
'
prefix
'
,
'
file1
'
),
(
'
file1.hdr file1.img file2.nii
'
,
'
file1
'
,
'
primary
'
,
'
file1.hdr
'
),
(
'
file1.hdr file1.img file2.nii
'
,
'
file1
'
,
'
all
'
,
'
file1.hdr file1.img
'
),
(
'
file1.hdr file1.img file2.nii
'
,
'
file1 file2
'
,
'
prefix
'
,
'
file1 file2
'
),
(
'
file1.hdr file1.img file2.nii
'
,
'
file1 file2
'
,
'
primary
'
,
'
file1.hdr file2.nii
'
),
(
'
file1.hdr file1.img file2.nii
'
,
'
file1 file2
'
,
'
all
'
,
'
file1.hdr file1.img file2.nii
'
),
# no file
(
'
file.nii
'
,
'
bag
'
,
'
prefix
'
,
''
),
(
'
file.nii
'
,
'
bag
'
,
'
primary
'
,
''
),
(
'
file.nii
'
,
'
bag
'
,
'
all
'
,
''
),
# incomplete prefix
(
'
file.nii
'
,
'
fi
'
,
'
prefix
'
,
''
),
(
'
file.nii
'
,
'
fi
'
,
'
primary
'
,
''
),
(
'
file.nii
'
,
'
fi
'
,
'
all
'
,
''
),
]
for
to_create
,
paths
,
output
,
expected
in
tests
:
with
testdir
(
to_create
.
split
())
as
td
:
paths
=
paths
.
split
()
expected
=
expected
.
split
()
result
=
imglob
.
imglob
(
paths
,
output
)
assert
sorted
(
result
)
==
sorted
(
expected
)
def
test_imglob_shouldFail
():
with
pytest
.
raises
(
ValueError
):
imglob
.
imglob
([],
'
bag
'
)
This diff is collapsed.
Click to expand it.
tests/test_scripts/test_imglob.py
+
78
−
2
View file @
0864bae2
#!/usr/bin/env python
#!/usr/bin/env python
import
mock
from
unittest
import
mock
import
pytest
import
fsl.scripts.imglob
as
imglob
import
fsl.scripts.imglob
as
imglob
...
@@ -8,7 +11,7 @@ from .. import testdir
...
@@ -8,7 +11,7 @@ from .. import testdir
from
..
import
CaptureStdout
from
..
import
CaptureStdout
def
test_imglob_
script_
shouldPass
():
def
test_imglob_shouldPass
1
():
# (files to create, args, expected)
# (files to create, args, expected)
tests
=
[
tests
=
[
...
@@ -50,8 +53,81 @@ def test_imglob_script_shouldPass():
...
@@ -50,8 +53,81 @@ def test_imglob_script_shouldPass():
assert
capture
.
stdout
.
strip
().
split
()
==
expected
.
split
()
assert
capture
.
stdout
.
strip
().
split
()
==
expected
.
split
()
def
test_imglob_shouldPass2
():
# (files to create, paths, output, expected)
tests
=
[
# normal usage, one file
(
'
file.hdr file.img
'
,
'
file
'
,
None
,
'
file
'
),
(
'
file.hdr file.img
'
,
'
file
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr file.img
'
,
'
file
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr file.img
'
,
'
file
'
,
'
all
'
,
'
file.hdr file.img
'
),
# incomplete file pair
(
'
file.hdr
'
,
'
file
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr
'
,
'
file.hdr
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr
'
,
'
file.img
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr
'
,
'
file
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file.hdr
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file.img
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file
'
,
'
all
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file.hdr
'
,
'
all
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file.img
'
,
'
all
'
,
'
file.hdr
'
),
# same file specified multiple times
(
'
file.hdr file.img
'
,
'
file file
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr file.img
'
,
'
file file.img
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr file.img
'
,
'
file file.img file.hdr
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr file.img
'
,
'
file file
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr file.img
'
,
'
file file.img
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr file.img
'
,
'
file file.img file.hdr
'
,
'
primary
'
,
'
file.hdr
'
),
(
'
file.hdr file.img
'
,
'
file file
'
,
'
all
'
,
'
file.hdr file.img
'
),
(
'
file.hdr file.img
'
,
'
file file.img
'
,
'
all
'
,
'
file.hdr file.img
'
),
(
'
file.hdr file.img
'
,
'
file file.img file.hdr
'
,
'
all
'
,
'
file.hdr file.img
'
),
# multiple files same prefix
(
'
file.hdr file.img file.nii
'
,
'
file
'
,
'
prefix
'
,
'
file
'
),
(
'
file.hdr file.img file.nii
'
,
'
file
'
,
'
primary
'
,
'
file.hdr file.nii
'
),
(
'
file.hdr file.img file.nii
'
,
'
file
'
,
'
all
'
,
'
file.hdr file.img file.nii
'
),
# multiple files
(
'
file1.hdr file1.img file2.nii
'
,
'
file1
'
,
'
prefix
'
,
'
file1
'
),
(
'
file1.hdr file1.img file2.nii
'
,
'
file1
'
,
'
primary
'
,
'
file1.hdr
'
),
(
'
file1.hdr file1.img file2.nii
'
,
'
file1
'
,
'
all
'
,
'
file1.hdr file1.img
'
),
(
'
file1.hdr file1.img file2.nii
'
,
'
file1 file2
'
,
'
prefix
'
,
'
file1 file2
'
),
(
'
file1.hdr file1.img file2.nii
'
,
'
file1 file2
'
,
'
primary
'
,
'
file1.hdr file2.nii
'
),
(
'
file1.hdr file1.img file2.nii
'
,
'
file1 file2
'
,
'
all
'
,
'
file1.hdr file1.img file2.nii
'
),
# no file
(
'
file.nii
'
,
'
bag
'
,
'
prefix
'
,
''
),
(
'
file.nii
'
,
'
bag
'
,
'
primary
'
,
''
),
(
'
file.nii
'
,
'
bag
'
,
'
all
'
,
''
),
# incomplete prefix
(
'
file.nii
'
,
'
fi
'
,
'
prefix
'
,
''
),
(
'
file.nii
'
,
'
fi
'
,
'
primary
'
,
''
),
(
'
file.nii
'
,
'
fi
'
,
'
all
'
,
''
),
]
for
to_create
,
paths
,
output
,
expected
in
tests
:
with
testdir
(
to_create
.
split
())
as
td
:
paths
=
paths
.
split
()
expected
=
expected
.
split
()
result
=
imglob
.
imglob
(
paths
,
output
)
assert
sorted
(
result
)
==
sorted
(
expected
)
def
test_imglob_script_shouldFail
():
def
test_imglob_script_shouldFail
():
with
pytest
.
raises
(
ValueError
):
imglob
.
imglob
([],
'
bag
'
)
capture
=
CaptureStdout
()
capture
=
CaptureStdout
()
with
capture
:
with
capture
:
...
...
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