Ejemplo n.º 1
0
 def test_set_initial_value(self):
     widget = OWWidget()
     variables = [ContinuousVariable(x) for x in "abc"]
     model = VariableListModel(variables)
     widget.foo = variables[1]
     combo = gui.comboBox(widget.controlArea, widget, "foo", model=model)
     self.assertEqual(combo.currentIndex(), 1)
Ejemplo n.º 2
0
 def test_set_initial_value(self):
     widget = OWWidget()
     variables = [ContinuousVariable(x) for x in "abc"]
     model = VariableListModel(variables)
     widget.foo = variables[1]
     combo = gui.comboBox(widget.controlArea, widget, "foo", model=model)
     self.assertEqual(combo.currentIndex(), 1)
Ejemplo n.º 3
0
    def test_select(self):
        widget = OWWidget()
        widget.foo = None
        self.attrs = VariableListModel()
        view = gui.listView(widget.controlArea, widget, "foo", model=self.attrs)
        self.assertIsNone(widget.foo)
        a, b, c = (ContinuousVariable(x) for x in "abc")
        self.attrs[:] = [a, b, c]
        view.setCurrentIndex(self.attrs.index(0, 0))
        self.assertIs(widget.foo, a)
        view.setCurrentIndex(self.attrs.index(2, 0))
        self.assertIs(widget.foo, c)

        widget.foo = b
        selection = view.selectedIndexes()
        self.assertEqual(len(selection), 1)
        self.assertEqual(selection[0].row(), 1)
Ejemplo n.º 4
0
    def test_select(self):
        widget = OWWidget()
        widget.foo = None
        self.attrs = VariableListModel()
        view = gui.listView(widget.controlArea, widget, "foo", model=self.attrs)
        self.assertIsNone(widget.foo)
        a, b, c = (ContinuousVariable(x) for x in "abc")
        self.attrs[:] = [a, b, c]
        view.setCurrentIndex(self.attrs.index(0, 0))
        self.assertIs(widget.foo, a)
        view.setCurrentIndex(self.attrs.index(2, 0))
        self.assertIs(widget.foo, c)

        widget.foo = b
        selection = view.selectedIndexes()
        self.assertEqual(len(selection), 1)
        self.assertEqual(selection[0].row(), 1)