diff --git a/IPython/html/widgets/tests/test_interaction.py b/IPython/html/widgets/tests/test_interaction.py index 6462c3f..91e8aaa 100644 --- a/IPython/html/widgets/tests/test_interaction.py +++ b/IPython/html/widgets/tests/test_interaction.py @@ -298,7 +298,7 @@ def test_default_values(): ) def test_default_out_of_bounds(): - @annotate(f=(0, 10.), h={'a': 1, 'b': 2}, j=['hi', 'there']) + @annotate(f=(0, 10.), h={'a': 1}, j=['hi', 'there']) def f(f='hi', h=5, j='other'): pass @@ -310,13 +310,13 @@ def test_default_out_of_bounds(): ), h=dict( cls=widgets.DropdownWidget, - values={'a': 1, 'b': 2}, - value=1 + values={'a': 1}, + value=1, ), j=dict( cls=widgets.DropdownWidget, values={'hi':'hi', 'there':'there'}, - value='hi' + value='hi', ), ) diff --git a/IPython/html/widgets/widget_selection.py b/IPython/html/widgets/widget_selection.py index 8216419..aa3f194 100644 --- a/IPython/html/widgets/widget_selection.py +++ b/IPython/html/widgets/widget_selection.py @@ -90,6 +90,8 @@ class _SelectionWidget(DOMWidget): # set the selected value name self.value_name = k return + # undo the change, and raise KeyError + self.value = old raise KeyError(new) finally: self.value_lock.release()