Skip to content

Commit e74b7e1

Browse files
committed
Explicitly test setting options traitlet
1 parent fffbd26 commit e74b7e1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

ipywidgets/widgets/tests/test_widget_selection.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ def test_raise_mapping_options(self):
2020
with pytest.raises(TypeError):
2121
Dropdown(options={'One': 1, 'Two': 2, 'Three': 3})
2222

23+
def test_setting_options_from_list(self):
24+
d = Dropdown()
25+
assert d.options == ()
26+
d.options = ['One', 'Two', 'Three']
27+
assert d.get_state('_options_labels') == {'_options_labels': ('One', 'Two', 'Three')}
28+
29+
def test_setting_options_from_list_tuples(self):
30+
d = Dropdown()
31+
assert d.options == ()
32+
d.options = [('One', 1), ('Two', 2), ('Three', 3)]
33+
assert d.get_state('_options_labels') == {'_options_labels': ('One', 'Two', 'Three')}
34+
d.value = 2
35+
assert d.get_state('index') == {'index': 1}
36+
37+
def test_setting_options_from_dict(self):
38+
d = Dropdown()
39+
assert d.options == ()
40+
with pytest.raises(TypeError):
41+
d.options = {'One': 1}
42+
2343

2444
class TestSelectionSlider(TestCase):
2545

0 commit comments

Comments
 (0)