24
24
from .. import minc1
25
25
from ..minc1 import Minc1File , Minc1Image , MincHeader
26
26
27
- from nose .tools import (assert_true , assert_equal , assert_false , assert_raises )
28
- from numpy .testing import assert_array_equal
29
27
from ..tmpdirs import InTemporaryDirectory
30
- from ..testing import data_path
28
+ from ..testing import (assert_true , assert_equal , assert_false , assert_raises , assert_warns ,
29
+ assert_array_equal , data_path , clear_and_catch_warnings )
31
30
32
31
from . import test_spatialimages as tsi
33
32
from .test_fileslice import slicer_samples
@@ -106,7 +105,8 @@ def test_old_namespace():
106
105
# Check warnings raised
107
106
arr = np .arange (24 ).reshape ((2 , 3 , 4 ))
108
107
aff = np .diag ([2 , 3 , 4 , 1 ])
109
- with warnings .catch_warnings (record = True ) as warns :
108
+ with clear_and_catch_warnings () as warns :
109
+ warnings .simplefilter ('always' , DeprecationWarning )
110
110
# Top level import.
111
111
# This import does not trigger an import of the minc.py module, because
112
112
# it's the proxy object.
@@ -122,7 +122,9 @@ def test_old_namespace():
122
122
# depending on whether the minc.py module is already imported in this
123
123
# test run.
124
124
if not previous_import :
125
- assert_equal (warns .pop (0 ).category , FutureWarning )
125
+ assert_equal (warns .pop (0 ).category , DeprecationWarning )
126
+
127
+ with clear_and_catch_warnings () as warns :
126
128
from .. import Minc1Image , MincImage
127
129
assert_equal (warns , [])
128
130
# The import from old module is the same as that from new
@@ -132,17 +134,17 @@ def test_old_namespace():
132
134
assert_equal (warns , [])
133
135
# Create object using old name
134
136
mimg = MincImage (arr , aff )
135
- assert_array_equal (mimg .get_data (), arr )
136
137
# Call to create object created warning
137
138
assert_equal (warns .pop (0 ).category , FutureWarning )
139
+ assert_array_equal (mimg .get_data (), arr )
138
140
# Another old name
139
141
from ..minc1 import MincFile , Minc1File
140
142
assert_false (MincFile is Minc1File )
141
143
assert_equal (warns , [])
142
144
mf = MincFile (netcdf_file (EG_FNAME ))
143
- assert_equal (mf .get_data_shape (), (10 , 20 , 20 ))
144
145
# Call to create object created warning
145
146
assert_equal (warns .pop (0 ).category , FutureWarning )
147
+ assert_equal (mf .get_data_shape (), (10 , 20 , 20 ))
146
148
147
149
148
150
class _TestMincFile (object ):
0 commit comments