Skip to content

Commit eef3687

Browse files
committed
TEST: Verify behavior when an input has a default and max_ver
1 parent 737e220 commit eef3687

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

nipype/interfaces/base/tests/test_core.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
275315
def test_output_version():
276316
class InputSpec(nib.TraitedSpec):
277317
foo = nib.traits.Int(desc="a random int")

0 commit comments

Comments
 (0)