File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,17 @@ def test_load_file_with_wrong_information(self):
153153 new_trk_file = trk_file [:996 ] + hdr_size + trk_file [996 + 4 :]
154154 assert_raises (HeaderError , TrkFile .load , BytesIO (new_trk_file ))
155155
156+ # Simulate a TRK file with a wrong scalar_name.
157+ trk_file = open (DATA ['complex_trk_fname' ], 'rb' ).read ()
158+ noise = np .int32 (42 ).tostring ()
159+ new_trk_file = trk_file [:47 ] + noise + trk_file [47 + 4 :]
160+ assert_raises (HeaderError , TrkFile .load , BytesIO (new_trk_file ))
161+
162+ # Simulate a TRK file with a wrong property_name.
163+ noise = np .int32 (42 ).tostring ()
164+ new_trk_file = trk_file [:254 ] + noise + trk_file [254 + 4 :]
165+ assert_raises (HeaderError , TrkFile .load , BytesIO (new_trk_file ))
166+
156167 def test_load_complex_file_in_big_endian (self ):
157168 trk_file = open (DATA ['complex_trk_big_endian_fname' ], 'rb' ).read ()
158169 # We use hdr_size as an indicator of little vs big endian.
Original file line number Diff line number Diff line change 1212import nibabel as nib
1313
1414from nibabel .openers import Opener
15- from nibabel .py3k import asbytes , asstr
15+ from nibabel .py3k import asstr
1616from nibabel .volumeutils import (native_code , swapped_code )
1717from nibabel .orientations import (aff2axcodes , axcodes2ornt )
1818
@@ -203,7 +203,7 @@ def decode_value_from_name(encoded_name):
203203 elif len (splits ) > 2 :
204204 # The remaining bytes are not \x00, raising.
205205 msg = ("Wrong scalar_name or property_name: '{}'."
206- " Unused characters should be \\ x00." ).format (name )
206+ " Unused characters should be \\ x00." ).format (encoded_name )
207207 raise HeaderError (msg )
208208
209209 return name , value
You can’t perform that action at this time.
0 commit comments