Skip to content

Commit 370dade

Browse files
committed
fixed hashing
1 parent b841310 commit 370dade

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

nipype/interfaces/tests/test_base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,20 @@ class spec2(nib.TraitedSpec):
205205
infields = spec2(moo=nme, doo=[tmp_infile])
206206
hashval = infields.get_hashval(hash_method='content')
207207
yield assert_equal, hashval[1], '642c326a05add933e9cdc333ce2d0ac2'
208+
209+
class spec3(nib.TraitedSpec):
210+
moo = nib.File(exists=True, name_source="doo")
211+
doo = nib.traits.List(nib.File(exists=True))
212+
infields = spec3(moo=nme, doo=[tmp_infile])
213+
hashval1 = infields.get_hashval(hash_method='content')
214+
215+
class spec4(nib.TraitedSpec):
216+
moo = nib.File(exists=True)
217+
doo = nib.traits.List(nib.File(exists=True))
218+
infields = spec4(moo=nme, doo=[tmp_infile])
219+
hashval2 = infields.get_hashval(hash_method='content')
220+
221+
yield assert_not_equal, hashval1[1], hashval2[1]
208222
os.chdir(pwd)
209223
teardown_file(tmpd)
210224

nipype/interfaces/traits_extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def has_metadata(trait, metadata, value=None, recursive=True):
235235
Checks if a given trait has a metadata (and optionally if it is set to particular value)
236236
'''
237237
count = 0
238-
if hasattr(trait, metadata) and (getattr(trait, metadata) == value or value==None):
238+
if metadata in trait._metadata.keys() and (trait._metadata[metadata] == value or value==None):
239239
count += 1
240240
if recursive:
241241
if hasattr(trait, 'inner_traits'):

0 commit comments

Comments
 (0)