Skip to content

Commit 287eae8

Browse files
author
Ben Cipollini
committed
Tweak error message, add all TypeError tests, localize properly.
1 parent d6e09de commit 287eae8

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

nibabel/gifti/gifti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def add_gifti_data_array(self, dataarr):
452452
dataarr : GiftiDataArray
453453
"""
454454
if not isinstance(dataarr, GiftiDataArray):
455-
raise TypeError("dataarr paramater must be of type GiftiDataArray")
455+
raise TypeError("Not a valid GiftiDataArray instance")
456456
self.darrays.append(dataarr)
457457

458458
def remove_gifti_data_array(self, ith):

nibabel/gifti/tests/test_gifti.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ def test_labeltable():
8080
img.labeltable = new_table
8181
assert_equal(len(img.labeltable.labels), 2)
8282

83-
# Try to set to non-table
84-
def assign_labeltable(val):
85-
img.labeltable = val
86-
assert_raises(TypeError, assign_labeltable, 'not-a-table')
87-
8883

8984
def test_metadata():
9085
# Test deprecation
@@ -156,4 +151,15 @@ def test_gifti_image():
156151
assert_true(img.meta is not None)
157152
assert_true(img.labeltable is not None)
158153

154+
# Try to set a non-data-array
159155
assert_raises(TypeError, img.add_gifti_data_array, 'not-a-data-array')
156+
157+
# Try to set to non-table
158+
def assign_labeltable(val):
159+
img.labeltable = val
160+
assert_raises(TypeError, assign_labeltable, 'not-a-table')
161+
162+
# Try to set to non-table
163+
def assign_metadata(val):
164+
img.meta = val
165+
assert_raises(TypeError, assign_metadata, 'not-a-meta')

0 commit comments

Comments
 (0)