Skip to content

Commit 3f40a3b

Browse files
committed
fix: Ignore warning that may not be emitted
1 parent 32a24e0 commit 3f40a3b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

nibabel/tests/test_processing.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""Testing processing module"""
1010

1111
import logging
12+
import warnings
1213
from os.path import dirname
1314
from os.path import join as pjoin
1415

@@ -169,7 +170,8 @@ def test_resample_from_to(caplog):
169170
exp_out[1:, :, :] = data[1, :, :]
170171
assert_almost_equal(out.dataobj, exp_out)
171172
out = resample_from_to(img, trans_p_25_img)
172-
with pytest.warns(UserWarning): # Suppress scipy warning
173+
with warnings.catch_warnings():
174+
warnings.simplefilter('ignore', UserWarning)
173175
exp_out = spnd.affine_transform(data, [1, 1, 1], [-0.25, 0, 0], order=3)
174176
assert_almost_equal(out.dataobj, exp_out)
175177
# Test cval
@@ -275,7 +277,8 @@ def test_resample_to_output(caplog):
275277
assert_array_equal(out_img.dataobj, np.flipud(data))
276278
# Subsample voxels
277279
out_img = resample_to_output(Nifti1Image(data, np.diag([4, 5, 6, 1])))
278-
with pytest.warns(UserWarning): # Suppress scipy warning
280+
with warnings.catch_warnings():
281+
warnings.simplefilter('ignore', UserWarning)
279282
exp_out = spnd.affine_transform(data, [1 / 4, 1 / 5, 1 / 6], output_shape=(5, 11, 19))
280283
assert_array_equal(out_img.dataobj, exp_out)
281284
# Unsubsample with voxel sizes

0 commit comments

Comments
 (0)