Skip to content

Commit

Permalink
Added two unit tests for Event parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Sep 22, 2020
1 parent 1ebe083 commit 9acb8bb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/API1/testwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SimpleWatchExample(param.Parameterized):
b = param.Parameter(default=0)
c = param.Parameter(default=0)
d = param.Integer(default=0)
e = param.Event()

def method(self, event):
self.b = self.a * 2
Expand Down Expand Up @@ -66,6 +67,10 @@ def _set_c(self):
def _set_d_bounds(self):
self.param.d.bounds = (self.c, self.c*2)

@param.depends('e', watch=True)
def _event_triggered(self):
assert self.e is True
self.d = 42

class WatchSubclassExample(WatchMethodExample):

Expand Down Expand Up @@ -482,6 +487,16 @@ def test_watch_deepcopy(self):
self.assertEqual(copied.b, 4)
self.assertEqual(obj.b, 0)

def test_watch_event_value_trigger(self):
obj = WatchMethodExample()
obj.e = True
self.assertEqual(obj.d, 42)

def test_watch_event_trigger_method(self):
obj = WatchMethodExample()
obj.param.trigger('e')
self.assertEqual(obj.d, 42)


class TestWatchMethod(API1TestCase):

Expand Down

0 comments on commit 9acb8bb

Please sign in to comment.