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):
153
153
new_trk_file = trk_file [:996 ] + hdr_size + trk_file [996 + 4 :]
154
154
assert_raises (HeaderError , TrkFile .load , BytesIO (new_trk_file ))
155
155
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
+
156
167
def test_load_complex_file_in_big_endian (self ):
157
168
trk_file = open (DATA ['complex_trk_big_endian_fname' ], 'rb' ).read ()
158
169
# We use hdr_size as an indicator of little vs big endian.
Original file line number Diff line number Diff line change 12
12
import nibabel as nib
13
13
14
14
from nibabel .openers import Opener
15
- from nibabel .py3k import asbytes , asstr
15
+ from nibabel .py3k import asstr
16
16
from nibabel .volumeutils import (native_code , swapped_code )
17
17
from nibabel .orientations import (aff2axcodes , axcodes2ornt )
18
18
@@ -203,7 +203,7 @@ def decode_value_from_name(encoded_name):
203
203
elif len (splits ) > 2 :
204
204
# The remaining bytes are not \x00, raising.
205
205
msg = ("Wrong scalar_name or property_name: '{}'."
206
- " Unused characters should be \\ x00." ).format (name )
206
+ " Unused characters should be \\ x00." ).format (encoded_name )
207
207
raise HeaderError (msg )
208
208
209
209
return name , value
You can’t perform that action at this time.
0 commit comments