@@ -719,23 +719,23 @@ def test_recoded_fields(self):
719719 assert hdr .get_value_label ('slice_code' ) == 'alternating decreasing'
720720
721721 def test_general_init (self ):
722- with clear_and_catch_warnings () as warns :
722+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
723723 warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
724724 warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
725725 warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
726726 UserWarning )
727727 super (TestNifti1PairHeader , self ).test_general_init ()
728728
729729 def test_from_header (self ):
730- with clear_and_catch_warnings () as warns :
730+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
731731 warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
732732 warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
733733 warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
734734 UserWarning )
735735 super (TestNifti1PairHeader , self ).test_from_header ()
736736
737737 def test_data_shape_zooms_affine (self ):
738- with clear_and_catch_warnings () as warns :
738+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
739739 warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
740740 warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
741741 warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
@@ -1207,7 +1207,7 @@ def test_zooms_edge_cases(self):
12071207 img = img_klass (arr , aff )
12081208
12091209 # Unknown units = 2 warnings
1210- with clear_and_catch_warnings () as warns :
1210+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
12111211 warnings .simplefilter ('always' )
12121212 assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
12131213 (1 , 1 , 1 , 1 ))
@@ -1216,7 +1216,7 @@ def test_zooms_edge_cases(self):
12161216 units = 'norm' , raise_unknown = True )
12171217
12181218 img .header .set_xyzt_units (xyz = 'meter' )
1219- with clear_and_catch_warnings () as warns :
1219+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
12201220 warnings .simplefilter ('always' )
12211221 assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
12221222 (1000 , 1000 , 1000 , 1 ))
@@ -1232,7 +1232,7 @@ def test_zooms_edge_cases(self):
12321232 (0.001 , 0.001 , 0.001 , 1 ))
12331233
12341234 img .header .set_xyzt_units (t = 'sec' )
1235- with clear_and_catch_warnings () as warns :
1235+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
12361236 warnings .simplefilter ('always' )
12371237 assert_array_equal (img .header .get_zooms (units = 'norm' ),
12381238 (1 , 1 , 1 , 1 ))
@@ -1277,7 +1277,7 @@ def test_zooms_edge_cases(self):
12771277
12781278 # Non-temporal t units are not transformed
12791279 img .header .set_zooms ((1 , 1 , 1 , 1.5 ), units = ('mm' , 'ppm' ))
1280- with clear_and_catch_warnings () as warns :
1280+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
12811281 warnings .simplefilter ('always' )
12821282 assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
12831283 (1 , 1 , 1 , 1.5 ))
@@ -1287,7 +1287,7 @@ def test_zooms_edge_cases(self):
12871287
12881288 # Non-temporal t units are not normalized
12891289 img .header .set_zooms ((2 , 2 , 2 , 3.5 ), units = 'norm' )
1290- with clear_and_catch_warnings () as warns :
1290+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
12911291 warnings .simplefilter ('always' )
12921292 assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
12931293 (2 , 2 , 2 , 3.5 ))
@@ -1310,7 +1310,7 @@ def test_zooms_edge_cases(self):
13101310 units = 'badparam' )
13111311
13121312 def test_no_finite_values (self ):
1313- with clear_and_catch_warnings () as warns :
1313+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
13141314 warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
13151315 warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
13161316 warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
0 commit comments