@@ -148,10 +148,10 @@ def test_list_str():
148
148
d = dict (
149
149
cls = widgets .Dropdown ,
150
150
value = first ,
151
+ options = tuple (values ),
151
152
_options_labels = tuple (values ),
152
153
_options_values = tuple (values ),
153
154
)
154
- d ['options' ] = tuple (zip (d ['_options_labels' ], d ['_options_values' ]))
155
155
check_widgets (c , lis = d )
156
156
157
157
def test_list_int ():
@@ -162,10 +162,9 @@ def test_list_int():
162
162
d = dict (
163
163
cls = widgets .Dropdown ,
164
164
value = first ,
165
- _options_labels = tuple (str (v ) for v in values ),
165
+ options = tuple ( values ), _options_labels = tuple (str (v ) for v in values ),
166
166
_options_values = tuple (values ),
167
167
)
168
- d ['options' ] = tuple (zip (d ['_options_labels' ], d ['_options_values' ]))
169
168
check_widgets (c , lis = d )
170
169
171
170
def test_list_tuple ():
@@ -176,10 +175,10 @@ def test_list_tuple():
176
175
d = dict (
177
176
cls = widgets .Dropdown ,
178
177
value = first ,
178
+ options = tuple (values ),
179
179
_options_labels = ("3" , "1" , "2" ),
180
180
_options_values = (300 , 100 , 200 ),
181
181
)
182
- d ['options' ] = tuple (zip (d ['_options_labels' ], d ['_options_values' ]))
183
182
check_widgets (c , lis = d )
184
183
185
184
def test_list_tuple_invalid ():
@@ -201,10 +200,10 @@ def test_dict():
201
200
cls = widgets .Dropdown ,
202
201
description = 'd' ,
203
202
value = next (iter (d .values ())),
203
+ options = d ,
204
204
_options_labels = tuple (d .keys ()),
205
205
_options_values = tuple (d .values ()),
206
206
)
207
- check ['options' ] = tuple (zip (check ['_options_labels' ], check ['_options_values' ]))
208
207
check_widget (w , ** check )
209
208
210
209
@@ -222,7 +221,6 @@ def test_ordereddict():
222
221
_options_labels = ("3" , "1" , "2" ),
223
222
_options_values = (300 , 100 , 200 ),
224
223
)
225
- d ['options' ] = tuple (zip (d ['_options_labels' ], d ['_options_values' ]))
226
224
check_widgets (c , lis = d )
227
225
228
226
def test_iterable ():
@@ -236,10 +234,10 @@ def yield_values():
236
234
d = dict (
237
235
cls = widgets .Dropdown ,
238
236
value = first ,
237
+ options = (3 , 1 , 2 ),
239
238
_options_labels = ("3" , "1" , "2" ),
240
239
_options_values = (3 , 1 , 2 ),
241
240
)
242
- d ['options' ] = tuple (zip (d ['_options_labels' ], d ['_options_values' ]))
243
241
check_widgets (c , lis = d )
244
242
245
243
def test_iterable_tuple ():
@@ -250,10 +248,10 @@ def test_iterable_tuple():
250
248
d = dict (
251
249
cls = widgets .Dropdown ,
252
250
value = first ,
251
+ options = tuple (values ),
253
252
_options_labels = ("3" , "1" , "2" ),
254
253
_options_values = (300 , 100 , 200 ),
255
254
)
256
- d ['options' ] = tuple (zip (d ['_options_labels' ], d ['_options_values' ]))
257
255
check_widgets (c , lis = d )
258
256
259
257
def test_mapping ():
@@ -278,10 +276,10 @@ def items(self):
278
276
d = dict (
279
277
cls = widgets .Dropdown ,
280
278
value = first ,
279
+ options = tuple (items ),
281
280
_options_labels = ("3" , "1" , "2" ),
282
281
_options_values = (300 , 100 , 200 ),
283
282
)
284
- d ['options' ] = tuple (zip (d ['_options_labels' ], d ['_options_values' ]))
285
283
check_widgets (c , lis = d )
286
284
287
285
@@ -327,12 +325,12 @@ def f(n, f=4.5, g=1, h=2, j='there'):
327
325
),
328
326
h = dict (
329
327
cls = widgets .Dropdown ,
330
- options = ( ('a' , 1 ), ('b' , 2 ) ),
328
+ options = OrderedDict ([ ('a' ,1 ), ('b' ,2 )] ),
331
329
value = 2
332
330
),
333
331
j = dict (
334
332
cls = widgets .Dropdown ,
335
- options = (( 'hi' , 'hi' ), ( ' there', 'there' ) ),
333
+ options = ('hi' , 'there' ),
336
334
value = 'there'
337
335
),
338
336
)
@@ -350,12 +348,12 @@ def f(f='hi', h=5, j='other'):
350
348
),
351
349
h = dict (
352
350
cls = widgets .Dropdown ,
353
- options = (( 'a' , 1 ),) ,
351
+ options = { 'a' : 1 } ,
354
352
value = 1 ,
355
353
),
356
354
j = dict (
357
355
cls = widgets .Dropdown ,
358
- options = (( 'hi' , 'hi' ), ( ' there', 'there' ) ),
356
+ options = ('hi' , 'there' ),
359
357
value = 'hi' ,
360
358
),
361
359
)
@@ -682,7 +680,7 @@ def test_multiple_selection():
682
680
683
681
# basic multiple select
684
682
w = smw (options = [(1 , 1 )], value = [1 ])
685
- check_widget (w , cls = smw , value = (1 ,), options = (('1' , 1 ),))
683
+ check_widget (w , cls = smw , value = (1 ,), options = ((1 , 1 ),))
686
684
687
685
# don't accept random other value
688
686
with nt .assert_raises (TraitError ):
@@ -691,20 +689,20 @@ def test_multiple_selection():
691
689
692
690
# change options, which resets value
693
691
w .options = w .options + ((2 , 2 ),)
694
- check_widget (w , options = (('1' , 1 ), ('2' ,2 )), value = ())
692
+ check_widget (w , options = ((1 , 1 ), (2 ,2 )), value = ())
695
693
696
694
# change value
697
695
w .value = (1 ,2 )
698
696
check_widget (w , value = (1 , 2 ))
699
697
700
698
# dict style
701
699
w .options = {1 : 1 }
702
- check_widget (w , options = (( '1' , 1 ),) )
700
+ check_widget (w , options = { 1 : 1 } )
703
701
704
702
# updating
705
703
with nt .assert_raises (TraitError ):
706
704
w .value = (2 ,)
707
- check_widget (w , options = (( '1' , 1 ),) )
705
+ check_widget (w , options = { 1 : 1 } )
708
706
709
707
710
708
def test_interact_noinspect ():
0 commit comments