Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Mar 5, 2021
1 parent 9786b2d commit acca37e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions panel/tests/test_depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,39 @@ def add(value, value2):
bound_function(1, 2)

assert bound_function(value2=5) == 6


def test_bind_bound_function_to_arg():
widget = IntSlider(value=1)

def add1(value):
return value + 1

def divide(value):
return value / 2

bound_function = bind(divide, bind(add1, widget.param.value))

assert bound_function() == 1

widget.value = 3

assert bound_function() == 2


def test_bind_bound_function_to_kwarg():
widget = IntSlider(value=1)

def add1(value):
return value + 1

def divide(divisor=2, value=0):
return value / divisor

bound_function = bind(divide, value=bind(add1, widget.param.value))

assert bound_function() == 1

widget.value = 3

assert bound_function() == 2

0 comments on commit acca37e

Please sign in to comment.