mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
undo failed changes
before raising otherwise, invalid values were still accepted
This commit is contained in:
parent
b51cc50357
commit
62f318c777
@ -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',
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user