Skip to content

Commit b5b623d

Browse files
satrachrisgorgo
authored andcommitted
fix: test that fails when traitedspec is not pickled properly
1 parent 200e944 commit b5b623d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

nipype/interfaces/tests/test_base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ class spec(nib.TraitedSpec):
9191
#yield assert_equal, infields.hashval[1], hashval[1]
9292
yield assert_equal, infields.__repr__(), '\nfoo = 1\ngoo = 0.0\n'
9393

94+
def test_TraitedSpec_dynamic():
95+
from cPickle import dumps, loads
96+
a = nib.BaseTraitedSpec()
97+
a.add_trait('foo', nib.traits.Int)
98+
a.foo = 1
99+
assign_a = lambda : setattr(a, 'foo', 'a')
100+
yield assert_raises, Exception, assign_a
101+
pkld_a = dumps(a)
102+
unpkld_a = loads(pkld_a)
103+
assign_a_again = lambda : setattr(unpkld_a, 'foo', 'a')
104+
yield assert_raises, Exception, assign_a_again
105+
94106
def test_TraitedSpec_logic():
95107
class spec3(nib.TraitedSpec):
96108
_xor_inputs = ('foo', 'bar')

0 commit comments

Comments
 (0)