Skip to content

Commit f4f3894

Browse files
committed
TEST: Check for illegal specs
1 parent 8ad9c32 commit f4f3894

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

nibabel/tests/test_arrayproxy.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def test_init():
8181
bio.write(arr.tostring(order='C'))
8282
ap = CArrayProxy(bio, FunkyHeader((2, 3, 4)))
8383
assert_array_equal(np.asarray(ap), arr)
84+
# Illegal init
85+
assert_raises(TypeError, ArrayProxy, bio, object())
8486

8587

8688
def test_tuplespec():
@@ -107,6 +109,13 @@ def test_tuplespec():
107109
# Tuple-defined ArrayProxies have no header to store
108110
with warnings.catch_warnings():
109111
assert_true(ap_tuple.header is None)
112+
# Partial tuples of length 2-4 are also valid
113+
for n in range(2, 5):
114+
ArrayProxy(bio, tuple_spec[:n])
115+
# Bad tuple lengths
116+
assert_raises(TypeError, ArrayProxy, bio, ())
117+
assert_raises(TypeError, ArrayProxy, bio, tuple_spec[:1])
118+
assert_raises(TypeError, ArrayProxy, bio, tuple_spec + ('error',))
110119

111120

112121
def write_raw_data(arr, hdr, fileobj):

0 commit comments

Comments
 (0)