@@ -245,15 +245,17 @@ class input_spec(nib.TraitedSpec):
245
245
246
246
_version = "misparsed-garbage"
247
247
248
- obj = DerivedInterface ()
248
+ with caplog .at_level (logging .WARNING , logger = "nipype.interface" ):
249
+ obj = DerivedInterface ()
250
+ assert len (caplog .records ) == 2
249
251
obj .inputs .foo = 1
250
252
obj .inputs .bar = 1
251
253
with caplog .at_level (logging .WARNING , logger = "nipype.interface" ):
252
254
obj ._check_version_requirements (obj .inputs )
253
- assert len (caplog .records ) == 2
255
+ assert len (caplog .records ) == 4
254
256
255
257
256
- def test_input_version_missing_error ():
258
+ def test_input_version_missing_error (caplog ):
257
259
from nipype import config
258
260
259
261
class DerivedInterface (nib .BaseInterface ):
@@ -263,13 +265,17 @@ class input_spec(nib.TraitedSpec):
263
265
264
266
_version = "misparsed-garbage"
265
267
266
- with mock .patch .object (config , "getboolean" , return_value = True ):
267
- obj = DerivedInterface (foo = 1 )
268
- with pytest .raises (ValueError ):
269
- obj ._check_version_requirements (obj .inputs )
270
- obj = DerivedInterface (bar = 1 )
271
- with pytest .raises (ValueError ):
272
- obj ._check_version_requirements (obj .inputs )
268
+ with caplog .at_level (logging .WARNING , logger = "nipype.interface" ):
269
+ obj1 = DerivedInterface (foo = 1 )
270
+ obj2 = DerivedInterface (bar = 1 )
271
+ assert len (caplog .records ) == 4
272
+ with caplog .at_level (logging .WARNING , logger = "nipype.interface" ):
273
+ with mock .patch .object (config , "getboolean" , return_value = True ):
274
+ with pytest .raises (ValueError ):
275
+ obj1 ._check_version_requirements (obj1 .inputs )
276
+ with pytest .raises (ValueError ):
277
+ obj2 ._check_version_requirements (obj2 .inputs )
278
+ assert len (caplog .records ) == 6
273
279
274
280
275
281
def test_unavailable_input ():
0 commit comments