1+ from Orange .data import ContinuousVariable
12from Orange .widgets import gui
23from Orange .widgets .tests .base import GuiTest
4+ from Orange .widgets .utils .itemmodels import VariableListModel
35from Orange .widgets .widget import OWWidget
46
57
6- class OWTestDoubleSpin (GuiTest ):
8+ class TestDoubleSpin (GuiTest ):
79 some_param = 0
810 some_option = False
911
@@ -13,3 +15,23 @@ def test_checked_extension(self):
1315 widget = OWWidget ()
1416 gui .doubleSpin (widget = widget , master = self , value = "some_param" ,
1517 minv = 1 , maxv = 10 , checked = "some_option" )
18+
19+
20+ class TestListModel (GuiTest ):
21+ def test_select (self ):
22+ widget = OWWidget ()
23+ widget .foo = None
24+ self .attrs = VariableListModel ()
25+ view = gui .listView (widget .controlArea , widget , "foo" , model = self .attrs )
26+ self .assertIsNone (widget .foo )
27+ a , b , c = (ContinuousVariable (x ) for x in "abc" )
28+ self .attrs [:] = [a , b , c ]
29+ view .setCurrentIndex (self .attrs .index (0 , 0 ))
30+ self .assertIs (widget .foo , a )
31+ view .setCurrentIndex (self .attrs .index (2 , 0 ))
32+ self .assertIs (widget .foo , c )
33+
34+ widget .foo = b
35+ selection = view .selectedIndexes ()
36+ self .assertEqual (len (selection ), 1 )
37+ self .assertEqual (selection [0 ].row (), 1 )
0 commit comments