File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ def _signature_matches_extension(filename):
5353 try :
5454 with open (filename , "rb" ) as fh :
5555 found_signature = fh .read (len (expected_signature ))
56- except Exception :
56+ except OSError :
5757 return False , f"Could not read file: { filename } "
5858 if found_signature == expected_signature :
5959 return True , ""
Original file line number Diff line number Diff line change @@ -78,14 +78,14 @@ def test_load_empty_image():
7878
7979@pytest .mark .parametrize ("extension" , [".gz" , ".bz2" ])
8080def test_load_bad_compressed_extension (tmp_path , extension ):
81- file_path = tmp_path . joinpath ( f"img.nii{ extension } " )
81+ file_path = tmp_path / f"img.nii{ extension } "
8282 file_path .write_bytes (b"bad" )
8383 with pytest .raises (ImageFileError , match = ".*is not a .* file" ):
8484 load (file_path )
8585
8686
8787def test_load_file_that_cannot_be_read (tmp_path ):
88- subdir = tmp_path . joinpath ( "img.nii.gz" )
88+ subdir = tmp_path / "img.nii.gz"
8989 subdir .mkdir ()
9090 with pytest .raises (ImageFileError , match = "Could not read" ):
9191 load (subdir )
You can’t perform that action at this time.
0 commit comments