1111from ....utils .filemanip import split_filename
1212from ... import base as nib
1313from ...base import traits , Undefined
14+ from ....interfaces import fsl
15+ from ...utility .wrappers import Function
16+ from ....pipeline import Node
17+
1418
1519standard_library .install_aliases ()
1620
@@ -47,6 +51,20 @@ class spec(nib.TraitedSpec):
4751 assert infields .__repr__ () == '\n foo = 1\n goo = 0.0\n '
4852
4953
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+
5068@pytest .mark .skip
5169def test_TraitedSpec_dynamic ():
5270 from pickle import dumps , loads
@@ -63,6 +81,36 @@ def test_TraitedSpec_dynamic():
6381 assign_a_again
6482
6583
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+
66114def test_TraitedSpec_logic ():
67115 class spec3 (nib .TraitedSpec ):
68116 _xor_inputs = ('foo' , 'bar' )
0 commit comments