File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 13
13
from ..loadsave import load , read_img_data , _signature_matches_extension
14
14
from ..filebasedimages import ImageFileError
15
15
from ..tmpdirs import InTemporaryDirectory , TemporaryDirectory
16
+ from ..openers import Opener
16
17
17
18
from ..optpkg import optional_package
18
19
_ , have_scipy , _ = optional_package ('scipy' )
@@ -82,6 +83,15 @@ def test_load_bad_compressed_extension(tmp_path, extension):
82
83
load (file_path )
83
84
84
85
86
+ @pytest .mark .parametrize ("extension" , [".gz" , ".bz2" ])
87
+ def test_load_good_extension_with_bad_data (tmp_path , extension ):
88
+ file_path = tmp_path / f"img.nii{ extension } "
89
+ with Opener (file_path , "wb" ) as fobj :
90
+ fobj .write (b"bad" )
91
+ with pytest .raises (ImageFileError , match = "Cannot work out file type of .*" ):
92
+ load (file_path )
93
+
94
+
85
95
def test_signature_matches_extension (tmp_path ):
86
96
gz_signature = b"\x1f \x8b "
87
97
good_file = tmp_path / "good.gz"
You can’t perform that action at this time.
0 commit comments