Show More
@@ -487,10 +487,54 b' def test_int_range_logic():' | |||||
487 | check_widget(w, cls=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) |
|
488 | w.value = (4, 2) | |
489 | check_widget(w, cls=irsw, value=(2, 4), min=0, max=6) |
|
489 | check_widget(w, cls=irsw, value=(2, 4), min=0, max=6) | |
|
490 | w.value = (-1, 7) | |||
|
491 | check_widget(w, cls=irsw, value=(0, 6), min=0, max=6) | |||
490 | w.min = 3 |
|
492 | w.min = 3 | |
491 |
check_widget(w, cls=irsw, value=(3, |
|
493 | check_widget(w, cls=irsw, value=(3, 6), min=3, max=6) | |
492 | w.max = 3 |
|
494 | w.max = 3 | |
493 | check_widget(w, cls=irsw, value=(3, 3), min=3, max=3) |
|
495 | check_widget(w, cls=irsw, value=(3, 3), min=3, max=3) | |
|
496 | ||||
|
497 | w.min = 0 | |||
|
498 | w.max = 6 | |||
|
499 | w.lower = 2 | |||
|
500 | w.upper = 4 | |||
|
501 | check_widget(w, cls=irsw, value=(2, 4), min=0, max=6) | |||
|
502 | w.value = (0, 1) #lower non-overlapping range | |||
|
503 | check_widget(w, cls=irsw, value=(0, 1), min=0, max=6) | |||
|
504 | w.value = (5, 6) #upper non-overlapping range | |||
|
505 | check_widget(w, cls=irsw, value=(5, 6), min=0, max=6) | |||
|
506 | w.value = (-1, 4) #semi out-of-range | |||
|
507 | check_widget(w, cls=irsw, value=(0, 4), min=0, max=6) | |||
|
508 | w.lower = 2 | |||
|
509 | check_widget(w, cls=irsw, value=(2, 4), min=0, max=6) | |||
|
510 | w.value = (-2, -1) #wholly out of range | |||
|
511 | check_widget(w, cls=irsw, value=(0, 0), min=0, max=6) | |||
|
512 | w.value = (7, 8) | |||
|
513 | check_widget(w, cls=irsw, value=(6, 6), min=0, max=6) | |||
|
514 | ||||
|
515 | with nt.assert_raises(ValueError): | |||
|
516 | w.min = 7 | |||
|
517 | with nt.assert_raises(ValueError): | |||
|
518 | w.max = -1 | |||
|
519 | with nt.assert_raises(ValueError): | |||
|
520 | w.lower = 5 | |||
|
521 | with nt.assert_raises(ValueError): | |||
|
522 | w.upper = 1 | |||
|
523 | ||||
|
524 | w = irsw(lower=5, min=0, max=6) | |||
|
525 | check_widget(w, lower=5) | |||
|
526 | w = irsw(upper=1, min=0, max=6) | |||
|
527 | check_widget(w, upper=1) | |||
|
528 | ||||
|
529 | with nt.assert_raises(ValueError): | |||
|
530 | irsw(value=(2, 4), lower=3) | |||
|
531 | with nt.assert_raises(ValueError): | |||
|
532 | irsw(value=(2, 4), upper=3) | |||
|
533 | with nt.assert_raises(ValueError): | |||
|
534 | irsw(value=(2, 4), lower=3, upper=3) | |||
|
535 | with nt.assert_raises(ValueError): | |||
|
536 | irsw(min=2, max=1) | |||
|
537 | ||||
494 |
|
538 | |||
495 | def test_float_range_logic(): |
|
539 | def test_float_range_logic(): | |
496 | frsw = widgets.FloatRangeSliderWidget |
|
540 | frsw = widgets.FloatRangeSliderWidget | |
@@ -498,7 +542,50 b' def test_float_range_logic():' | |||||
498 | check_widget(w, cls=frsw, value=(.2, .4), min=0., max=.6) |
|
542 | check_widget(w, cls=frsw, value=(.2, .4), min=0., max=.6) | |
499 | w.value = (.4, .2) |
|
543 | w.value = (.4, .2) | |
500 | check_widget(w, cls=frsw, value=(.2, .4), min=0., max=.6) |
|
544 | check_widget(w, cls=frsw, value=(.2, .4), min=0., max=.6) | |
|
545 | w.value = (-.1, .7) | |||
|
546 | check_widget(w, cls=frsw, value=(0., .6), min=0., max=.6) | |||
501 | w.min = .3 |
|
547 | w.min = .3 | |
502 |
check_widget(w, cls=frsw, value=(.3, . |
|
548 | check_widget(w, cls=frsw, value=(.3, .6), min=.3, max=.6) | |
503 | w.max = .3 |
|
549 | w.max = .3 | |
504 | check_widget(w, cls=frsw, value=(.3, .3), min=.3, max=.3) |
|
550 | check_widget(w, cls=frsw, value=(.3, .3), min=.3, max=.3) | |
|
551 | ||||
|
552 | w.min = 0. | |||
|
553 | w.max = .6 | |||
|
554 | w.lower = .2 | |||
|
555 | w.upper = .4 | |||
|
556 | check_widget(w, cls=frsw, value=(.2, .4), min=0., max=.6) | |||
|
557 | w.value = (0., .1) #lower non-overlapping range | |||
|
558 | check_widget(w, cls=frsw, value=(0., .1), min=0., max=.6) | |||
|
559 | w.value = (.5, .6) #upper non-overlapping range | |||
|
560 | check_widget(w, cls=frsw, value=(.5, .6), min=0., max=.6) | |||
|
561 | w.value = (-.1, .4) #semi out-of-range | |||
|
562 | check_widget(w, cls=frsw, value=(0., .4), min=0., max=.6) | |||
|
563 | w.lower = .2 | |||
|
564 | check_widget(w, cls=frsw, value=(.2, .4), min=0., max=.6) | |||
|
565 | w.value = (-.2, -.1) #wholly out of range | |||
|
566 | check_widget(w, cls=frsw, value=(0., 0.), min=0., max=.6) | |||
|
567 | w.value = (.7, .8) | |||
|
568 | check_widget(w, cls=frsw, value=(.6, .6), min=.0, max=.6) | |||
|
569 | ||||
|
570 | with nt.assert_raises(ValueError): | |||
|
571 | w.min = .7 | |||
|
572 | with nt.assert_raises(ValueError): | |||
|
573 | w.max = -.1 | |||
|
574 | with nt.assert_raises(ValueError): | |||
|
575 | w.lower = .5 | |||
|
576 | with nt.assert_raises(ValueError): | |||
|
577 | w.upper = .1 | |||
|
578 | ||||
|
579 | w = frsw(lower=.5, min=0., max=.6) | |||
|
580 | check_widget(w, lower=.5) | |||
|
581 | w = frsw(upper=.1, min=0., max=.6) | |||
|
582 | check_widget(w, upper=.1) | |||
|
583 | ||||
|
584 | with nt.assert_raises(ValueError): | |||
|
585 | frsw(value=(2, 4), lower=3) | |||
|
586 | with nt.assert_raises(ValueError): | |||
|
587 | frsw(value=(2, 4), upper=3) | |||
|
588 | with nt.assert_raises(ValueError): | |||
|
589 | frsw(value=(2, 4), lower=3, upper=3) | |||
|
590 | with nt.assert_raises(ValueError): | |||
|
591 | frsw(min=.2, max=.1) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now