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
378f7bbc
Commit
378f7bbc
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Test invalid image file
parent
678438c7
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_image.py
+9
-6
9 additions, 6 deletions
tests/test_image.py
with
9 additions
and
6 deletions
tests/test_image.py
+
9
−
6
View file @
378f7bbc
...
...
@@ -13,6 +13,8 @@ import glob
import
numpy
as
np
import
nibabel
as
nib
from
nibabel.spatialimages
import
HeaderDataError
import
fsl.data.constants
as
constants
import
fsl.data.image
as
fslimage
import
fsl.utils.path
as
fslpath
...
...
@@ -44,18 +46,19 @@ def test_load(testdir):
'
ambiguous.img
'
,
'
ambiguous.hdr.gz
'
,
'
ambiguous.img.gz
'
]
shouldRaise
=
[
'
notexist
'
,
'
notexist.nii.gz
'
,
'
ambiguous
'
]
shouldRaise
=
[(
'
notexist
'
,
fslpath
.
PathError
),
(
'
notexist.nii.gz
'
,
fslpath
.
PathError
),
(
'
ambiguous
'
,
fslpath
.
PathError
),
(
'
notnifti
'
,
HeaderDataError
),
(
'
notnifti.nii.gz
'
,
HeaderDataError
)]
# Not raising an error means the test passes
for
fname
in
shouldPass
:
fslimage
.
Image
(
op
.
join
(
testdir
,
'
nifti_formats
'
,
fname
))
# These should raise an error
for
fname
in
shouldRaise
:
with
pytest
.
raises
(
fslpath
.
PathError
):
print
fname
for
fname
,
exc
in
shouldRaise
:
with
pytest
.
raises
(
exc
):
fslimage
.
Image
(
op
.
join
(
testdir
,
'
nifti_formats
'
,
fname
))
...
...
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