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