def test_discrete_editor(self): w = DiscreteVariableEditor() self.assertIs(w.get_data(), None) v = DiscreteVariable("C", values=["a", "b", "c"]) v.attributes.update({"A": 1, "B": "b"}) w.set_data(v) self.assertEqual(w.name_edit.text(), v.name) self.assertEqual(w.labels_model.get_dict(), v.attributes) self.assertTrue(w.is_same()) w.set_data(None) self.assertEqual(w.name_edit.text(), "") self.assertEqual(w.labels_model.get_dict(), {}) self.assertIs(w.get_data(), None) # test selection/deselection in the view w.set_data(v) view = w.values_edit model = view.model() assert model.rowCount() sel_model = view.selectionModel() model = sel_model.model() sel_model.select(model.index(0, 0), QItemSelectionModel.Select) sel_model.select(model.index(0, 0), QItemSelectionModel.Deselect)
def test_discrete_editor(self): w = DiscreteVariableEditor() self.assertIs(w.get_data(), None) v = DiscreteVariable("C", values=["a", "b", "c"]) v.attributes.update({"A": 1, "B": "b"}) w.set_data(v) self.assertEqual(w.name_edit.text(), v.name) self.assertEqual(w.labels_model.get_dict(), v.attributes) self.assertTrue(w.is_same()) w.set_data(None) self.assertEqual(w.name_edit.text(), "") self.assertEqual(w.labels_model.get_dict(), {}) self.assertIs(w.get_data(), None)
def test_discrete_editor(self): w = DiscreteVariableEditor() self.assertIs(w.get_data(), None) v = DiscreteVariable("C", values=["a", "b", "c"]) v.attributes.update({"A": 1, "B": "b"}) w.set_data(v) self.assertEqual(w.name_edit.text(), v.name) self.assertEqual(w.labels_model.get_dict(), v.attributes) self.assertTrue(w.is_same()) w.set_data(None) self.assertEqual(w.name_edit.text(), "") self.assertEqual(w.labels_model.get_dict(), {}) self.assertIs(w.get_data(), None)