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 1313from ..loadsave import load , read_img_data , _signature_matches_extension
1414from ..filebasedimages import ImageFileError
1515from ..tmpdirs import InTemporaryDirectory , TemporaryDirectory
16+ from ..openers import Opener
1617
1718from ..optpkg import optional_package
1819_ , have_scipy , _ = optional_package ('scipy' )
@@ -82,6 +83,15 @@ def test_load_bad_compressed_extension(tmp_path, extension):
8283 load (file_path )
8384
8485
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+
8595def test_signature_matches_extension (tmp_path ):
8696 gz_signature = b"\x1f \x8b "
8797 good_file = tmp_path / "good.gz"
You can’t perform that action at this time.
0 commit comments