Skip to content

Commit a1bfa76

Browse files
Michiel CottaarMichiel Cottaar
authored andcommitted
TEST: add tests to check that warnings are raised
1 parent 5888a12 commit a1bfa76

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

nibabel/cifti2/tests/test_cifti2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from nibabel import cifti2 as ci
99
from nibabel.nifti2 import Nifti2Header
10-
from nibabel.cifti2.cifti2 import _float_01, _value_if_klass, Cifti2HeaderError, Cifti2NamedMap, Cifti2MatrixIndicesMap
10+
from nibabel.cifti2.cifti2 import _float_01, _value_if_klass, Cifti2HeaderError
1111

1212
from nose.tools import assert_true, assert_equal, assert_raises, assert_is_none
1313

@@ -359,7 +359,7 @@ class TestCifti2ImageAPI(_TDA):
359359

360360
def make_imaker(self, arr, header=None, ni_header=None):
361361
for idx, sz in enumerate(arr.shape):
362-
maps = [Cifti2NamedMap(str(value)) for value in range(sz)]
362+
maps = [ci.Cifti2NamedMap(str(value)) for value in range(sz)]
363363
mim = ci.Cifti2MatrixIndicesMap(
364364
(idx, ), 'CIFTI_INDEX_TYPE_SCALARS', maps=maps
365365
)

nibabel/cifti2/tests/test_new_cifti2.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from nibabel.tmpdirs import InTemporaryDirectory
1414

1515
from nose.tools import assert_true, assert_equal, assert_raises
16+
from nibabel.testing import clear_and_catch_warnings, error_warnings, suppress_warnings
1617

1718
affine = [[-1.5, 0, 0, 90],
1819
[0, 1.5, 0, -85],
@@ -516,6 +517,10 @@ def test_wrong_shape():
516517
np.random.randn(3, 10),
517518
np.random.randn(2, 9),
518519
):
519-
img = ci.Cifti2Image(data, hdr)
520+
with clear_and_catch_warnings():
521+
with error_warnings():
522+
assert_raises(UserWarning, ci.Cifti2Image, data, hdr)
523+
with suppress_warnings():
524+
img = ci.Cifti2Image(data, hdr)
520525
assert_raises(ValueError, img.to_file_map)
521526

0 commit comments

Comments
 (0)