def test_setData_on_last_row_extends_array(self):
     model = ArrayModel()
     model.reset(Array([5.0]))
     self.assertTrue(model.setData(model.index(1, 0), 2.3))
     self.assertEqual(model.rowCount(), 3)
     self.assertEqual(model.index(0, 0).data(), 5.0)
     self.assertEqual(model.index(1, 0).data(), 2.3)
Example #2
0
 def test_errors_in_cells_are_marked_by_ErrorCell(self):
     model = ArrayModel()
     index = model.index(0, 0)
     self.assertTrue(model.setData(index, "This won't work"))
     self.assertEqual(model.data(index, Qt.DisplayRole), "Error")
     self.assertEqual(
         model.data(index, Qt.ToolTipRole),
         "Cannot parse: Could not decode the value: Expecting value: line 1 column 1 (char 0)",
     )
     self.assertEqual(model.data(index, Qt.EditRole), "This won't work")
 def test_setData(self):
     model = ArrayModel()
     model.reset(Array([5.0]))
     self.assertTrue(model.setData(model.index(0, 0), 2.3))
     self.assertEqual(model.rowCount(), 2)
     self.assertEqual(model.index(0, 0).data(), 2.3)