File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
nipype/interfaces/base/tests Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,46 @@ class input_spec(nib.TraitedSpec):
272272 obj ._check_version_requirements (obj .inputs )
273273
274274
275+ def test_unavailable_input ():
276+ class WithInput (nib .BaseInterface ):
277+ class input_spec (nib .TraitedSpec ):
278+ foo = nib .traits .Int (3 , usedefault = True , max_ver = "0.5" )
279+
280+ _version = "0.4"
281+
282+ def _run_interface (self , runtime ):
283+ return runtime
284+
285+ class WithoutInput (WithInput ):
286+ _version = "0.6"
287+
288+ has = WithInput ()
289+ hasnt = WithoutInput ()
290+ trying_anyway = WithoutInput (foo = 3 )
291+ assert has .inputs .foo == 3
292+ assert not nib .isdefined (hasnt .inputs .foo )
293+ assert trying_anyway .inputs .foo == 3
294+
295+ has .run ()
296+ hasnt .run ()
297+ with pytest .raises (Exception ):
298+ trying_anyway .run ()
299+
300+ # Still settable
301+ has .inputs .foo = 4
302+ hasnt .inputs .foo = 4
303+ trying_anyway .inputs .foo = 4
304+ assert has .inputs .foo == 4
305+ assert hasnt .inputs .foo == 4
306+ assert trying_anyway .inputs .foo == 4
307+
308+ has .run ()
309+ with pytest .raises (Exception ):
310+ hasnt .run ()
311+ with pytest .raises (Exception ):
312+ trying_anyway .run ()
313+
314+
275315def test_output_version ():
276316 class InputSpec (nib .TraitedSpec ):
277317 foo = nib .traits .Int (desc = "a random int" )
You can’t perform that action at this time.
0 commit comments