Skip to content

Commit

Permalink
Merge dfa0e61 into a99b3f6
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickinson committed Jul 9, 2018
2 parents a99b3f6 + dfa0e61 commit 3ce14a0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
11 changes: 9 additions & 2 deletions traits/has_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2562,8 +2562,15 @@ def on_trait_change ( self, handler, name = None, remove = False,

if isinstance( name, list ):
for name_i in name:
self.on_trait_change( handler, name_i, remove, dispatch,
priority, target )
self.on_trait_change(
handler,
name=name_i,
remove=remove,
dispatch=dispatch,
priority=priority,
deferred=deferred,
target=target,
)

return

Expand Down
20 changes: 20 additions & 0 deletions traits/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ def _get_y(self):
return self.x + 1


class ExtendedListenerInList(HasTraits):
# Used in regression test for enthought/traits#403.

dummy = Instance(Dummy)

changed = Bool(False)

@on_trait_change(['dummy:x'])
def set_changed(self):
self.changed = True


class TestRegression(unittest.TestCase):

def test_default_value_for_no_cache(self):
Expand Down Expand Up @@ -211,6 +223,14 @@ class MultiArrayDataSource(HasTraits):
# later.
round(3.14159, 2)

def test_on_trait_change_with_list_of_extended_names(self):
# Regression test for enthought/traits#403
dummy = Dummy(x=10)
model = ExtendedListenerInList(dummy=dummy)
self.assertFalse(model.changed)
dummy.x = 11
self.assertTrue(model.changed)


if __name__ == '__main__':
unittest.main()

0 comments on commit 3ce14a0

Please sign in to comment.