11
11
from ....utils .filemanip import split_filename
12
12
from ... import base as nib
13
13
from ...base import traits , Undefined
14
+ from ....interfaces import fsl
15
+ from ...utility .wrappers import Function
16
+ from ....pipeline import Node
17
+
14
18
15
19
standard_library .install_aliases ()
16
20
@@ -47,6 +51,20 @@ class spec(nib.TraitedSpec):
47
51
assert infields .__repr__ () == '\n foo = 1\n goo = 0.0\n '
48
52
49
53
54
+ def test_TraitedSpec_tab_completion ():
55
+ bet_nd = Node (fsl .BET (), name = 'bet' )
56
+ bet_interface = fsl .BET ()
57
+ bet_inputs = bet_nd .inputs .class_editable_traits ()
58
+ bet_outputs = bet_nd .outputs .class_editable_traits ()
59
+
60
+ # Check __all__ for bet node and interface inputs
61
+ assert set (bet_nd .inputs .__all__ ) == set (bet_inputs )
62
+ assert set (bet_interface .inputs .__all__ ) == set (bet_inputs )
63
+
64
+ # Check __all__ for bet node outputs
65
+ assert set (bet_nd .outputs .__all__ ) == set (bet_outputs )
66
+
67
+
50
68
@pytest .mark .skip
51
69
def test_TraitedSpec_dynamic ():
52
70
from pickle import dumps , loads
@@ -63,6 +81,36 @@ def test_TraitedSpec_dynamic():
63
81
assign_a_again
64
82
65
83
84
+ def test_DynamicTraitedSpec_tab_completion ():
85
+ def extract_func (list_out ):
86
+ return list_out [0 ]
87
+
88
+ # Define interface
89
+ func_interface = Function (input_names = ["list_out" ],
90
+ output_names = ["out_file" , "another_file" ],
91
+ function = extract_func )
92
+ # Define node
93
+ list_extract = Node (Function (
94
+ input_names = ["list_out" ], output_names = ["out_file" ],
95
+ function = extract_func ), name = "list_extract" )
96
+
97
+ # Check __all__ for interface inputs
98
+ expected_input = set (list_extract .inputs .editable_traits ())
99
+ assert (set (func_interface .inputs .__all__ ) == expected_input )
100
+
101
+ # Check __all__ for node inputs
102
+ assert (set (list_extract .inputs .__all__ ) == expected_input )
103
+
104
+ # Check __all__ for node outputs
105
+ expected_output = set (list_extract .outputs .editable_traits ())
106
+ assert (set (list_extract .outputs .__all__ ) == expected_output )
107
+
108
+ # Add trait and retest
109
+ list_extract ._interface ._output_names .append ('added_out_trait' )
110
+ expected_output .add ('added_out_trait' )
111
+ assert (set (list_extract .outputs .__all__ ) == expected_output )
112
+
113
+
66
114
def test_TraitedSpec_logic ():
67
115
class spec3 (nib .TraitedSpec ):
68
116
_xor_inputs = ('foo' , 'bar' )
0 commit comments