Skip to content

Commit

Permalink
Merge f9adaf8 into 0271d04
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 31, 2019
2 parents 0271d04 + f9adaf8 commit 88bb605
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions param/parameterized.py
Expand Up @@ -1383,8 +1383,8 @@ def trigger(self_, *param_names):
self_.self_or_cls.param._TRIGGER = True
self_.set_param(**params)
self_.self_or_cls.param._TRIGGER = False
self_.self_or_cls.param._events = events
self_.self_or_cls.param._watchers = watchers
self_.self_or_cls.param._events += events
self_.self_or_cls.param._watchers += watchers


def _update_event_type(self_, watcher, event, triggered):
Expand Down
15 changes: 15 additions & 0 deletions tests/API1/testwatch.py
Expand Up @@ -617,6 +617,21 @@ def test_simple_trigger_one_param(self):
self.assertEqual(args[0].new, 0)
self.assertEqual(args[0].type, 'triggered')

def test_simple_trigger_when_batched(self):
accumulator = Accumulator()
obj = SimpleWatchExample()
obj.param.watch(accumulator, ['a'])
with param.batch_watch(obj):
obj.param.trigger('a')
self.assertEqual(accumulator.call_count(), 1)

args = accumulator.args_for_call(0)
self.assertEqual(args[0].name, 'a')
self.assertEqual(args[0].old, 0)
self.assertEqual(args[0].new, 0)
# Note: This is not strictly correct
self.assertEqual(args[0].type, 'changed')

def test_simple_trigger_one_param_change(self):
accumulator = Accumulator()
obj = SimpleWatchExample()
Expand Down

0 comments on commit 88bb605

Please sign in to comment.