##// END OF EJS Templates
Remove tests for 4-5 tuples, add tests for validate logic
Gordon Ball -
Show More
@@ -220,84 +220,6 b' def test_list_tuple_3_float():'
220 220 )
221 221 check_widgets(c, tup=d, lis=d)
222 222
223 def test_list_tuple_4_int():
224 with nt.assert_raises(ValueError):
225 c = interactive(f, tup=(4, 3, 2, 1))
226 with nt.assert_raises(ValueError):
227 c = interactive(f, tup=(1, 2, 3, 2))
228 with nt.assert_raises(ValueError):
229 c = interactive(f, tup=(2, 1, 3, 4))
230 for min, low, high, max in [(0, 1, 2, 3), (0, 0, 0, 0), (1, 2, 2, 3), (-2, -1, 1, 2)]:
231 c = interactive(f, tup=(min, low, high, max), lis=[min, low, high, max])
232 nt.assert_equal(len(c.children), 2)
233 d = dict(
234 cls=widgets.IntRangeSliderWidget,
235 min=min,
236 max=max,
237 value=(low, high),
238 range=True,
239 readout=True
240 )
241 check_widgets(c, tup=d, lis=d)
242
243 def test_list_tuple_5_int():
244 with nt.assert_raises(ValueError):
245 c = interactive(f, tup=(1, 2, 3, 4, 0))
246 with nt.assert_raises(ValueError):
247 c = interactive(f, tup=(1, 2, 3, 4, -1))
248 for min, low, high, max, step in [(0, 1, 2, 3, 1), (0, 0, 0, 0, 1), (1, 2, 2, 3, 2), (-2, -1, 1, 2, 3)]:
249 c = interactive(f, tup=(min, low, high, max, step), lis=[min, low, high, max, step])
250 nt.assert_equal(len(c.children), 2)
251 d = dict(
252 cls=widgets.IntRangeSliderWidget,
253 min=min,
254 max=max,
255 value=(low, high),
256 step=step,
257 range=True,
258 readout=True
259 )
260 check_widgets(c, tup=d, lis=d)
261
262 def test_list_tuple_4_float():
263 with nt.assert_raises(ValueError):
264 c = interactive(f, tup=(4, 3., 2, 1))
265 with nt.assert_raises(ValueError):
266 c = interactive(f, tup=(1, 2, 3, 2.))
267 with nt.assert_raises(ValueError):
268 c = interactive(f, tup=(2, 1., 3, 4))
269 for min, low, high, max in [(0, 1., 2, 3), (0, 0, 0., 0), (1., 2., 2., 3.1415), (-2.5, -1, 1, 2.5)]:
270 c = interactive(f, tup=(min, low, high, max), lis=[min, low, high, max])
271 nt.assert_equal(len(c.children), 2)
272 d = dict(
273 cls=widgets.FloatRangeSliderWidget,
274 min=min,
275 max=max,
276 value=(low, high),
277 range=True,
278 readout=True
279 )
280 check_widgets(c, tup=d, lis=d)
281
282 def test_list_tuple_5_float():
283 with nt.assert_raises(ValueError):
284 c = interactive(f, tup=(1, 2., 3., 4, 0))
285 with nt.assert_raises(ValueError):
286 c = interactive(f, tup=(1, 2, 3., 4., -0.5))
287 for min, low, high, max, step in [(0, 1, 2, 3, 0.01), (0, 0, 0, 0, 0.1), (1, 2, 2, 3, 2.718), (-2, -1.5, 1.5, 2, 2)]:
288 c = interactive(f, tup=(min, low, high, max, step), lis=[min, low, high, max, step])
289 nt.assert_equal(len(c.children), 2)
290 d = dict(
291 cls=widgets.FloatRangeSliderWidget,
292 min=min,
293 max=max,
294 value=(low, high),
295 step=step,
296 range=True,
297 readout=True
298 )
299 check_widgets(c, tup=d, lis=d)
300
301 223 def test_list_tuple_str():
302 224 values = ['hello', 'there', 'guy']
303 225 first = values[0]
@@ -558,3 +480,25 b' def test_custom_description():'
558 480 value='text',
559 481 description='foo',
560 482 )
483
484 def test_int_range_logic():
485 irsw = widgets.IntRangeSliderWidget
486 w = irsw(value=(2, 4), min=0, max=6)
487 check_widget(w, cls=irsw, value=(2, 4), min=0, max=6)
488 w.value = (4, 2)
489 check_widget(w, cls=irsw, value=(2, 4), min=0, max=6)
490 w.min = 3
491 check_widget(w, cls=irsw, value=(3, 4), min=3, max=6)
492 w.max = 3
493 check_widget(w, cls=irsw, value=(3, 3), min=3, max=3)
494
495 def test_float_range_logic():
496 frsw = widgets.FloatRangeSliderWidget
497 w = frsw(value=(.2, .4), min=0., max=.6)
498 check_widget(w, cls=frsw, value=(.2, .4), min=0., max=.6)
499 w.value = (.4, .2)
500 check_widget(w, cls=frsw, value=(.2, .4), min=0., max=.6)
501 w.min = .3
502 check_widget(w, cls=frsw, value=(.3, .4), min=.3, max=.6)
503 w.max = .3
504 check_widget(w, cls=frsw, value=(.3, .3), min=.3, max=.3)
General Comments 0
You need to be logged in to leave comments. Login now