@@ -172,11 +172,13 @@ class DeprecationSpec3(nib.TraitedSpec):
172172 yield assert_equal , spec_instance .foo , Undefined
173173 yield assert_equal , spec_instance .bar , 1
174174
175+
175176def test_namesource ():
176177 tmp_infile = setup_file ()
177178 tmpd , nme , ext = split_filename (tmp_infile )
178179 pwd = os .getcwd ()
179180 os .chdir (tmpd )
181+
180182 class spec2 (nib .CommandLineInputSpec ):
181183 moo = nib .File (name_source = ['doo' ], hash_files = False , argstr = "%s" ,
182184 position = 2 )
@@ -196,6 +198,33 @@ class TestName(nib.CommandLine):
196198 os .chdir (pwd )
197199 teardown_file (tmpd )
198200
201+
202+ def test_chained_namesource ():
203+ tmp_infile = setup_file ()
204+ tmpd , nme , ext = split_filename (tmp_infile )
205+ pwd = os .getcwd ()
206+ os .chdir (tmpd )
207+
208+ class spec2 (nib .CommandLineInputSpec ):
209+ doo = nib .File (exists = True , argstr = "%s" , position = 1 )
210+ moo = nib .File (name_source = ['doo' ], hash_files = False , argstr = "%s" ,
211+ position = 2 , name_template = '%s_mootpl' )
212+ poo = nib .File (name_source = ['moo' ], hash_files = False ,
213+ argstr = "%s" , position = 3 )
214+
215+ class TestName (nib .CommandLine ):
216+ _cmd = "mycommand"
217+ input_spec = spec2
218+
219+ testobj = TestName ()
220+ testobj .inputs .doo = tmp_infile
221+ yield assert_true , '%s_mootpl' % nme in testobj .cmdline
222+ yield assert_true , '%s_mootpl_generated' % nme in testobj .cmdline
223+
224+ os .chdir (pwd )
225+ teardown_file (tmpd )
226+
227+
199228def checknose ():
200229 """check version of nose for known incompatability"""
201230 mod = __import__ ('nose' )
@@ -536,4 +565,4 @@ def test_global_CommandLine_output():
536565 res = ci .run ()
537566 yield assert_equal , res .runtime .stdout , ''
538567 os .chdir (pwd )
539- teardown_file (tmpd )
568+ teardown_file (tmpd )
0 commit comments