Пример #1
0
def test_addRemoveRows(qtbot, open_window):
    table_model = CalibrationTableModel()
    table_view = open_window(CalibrationTableView)
    table_view.setModel(table_model)

    starting_count = table_model.rowCount()

    #Find a QRect of a row
    cell_rect = table_view.visualRect(table_model.index(1,1,QtCore.QModelIndex()))

    #Add One After
    table_view.setSelection(cell_rect, QtCore.QItemSelectionModel.Select)
    table_view.addRowAfterSelected()
    assert (starting_count+1) ==  table_model.rowCount()
    qtbot.wait(TestingFlags.TEST_WAIT_SHORT)

    #Remove One
    table_view.setSelection(cell_rect, QtCore.QItemSelectionModel.Select)
    table_view.removeSelectedRow()
    assert (starting_count) ==  table_model.rowCount()
    qtbot.wait(TestingFlags.TEST_WAIT_SHORT)

    #Add One Before
    table_view.setSelection(cell_rect, QtCore.QItemSelectionModel.Select)
    table_view.addRowBeforeSelected()
    assert (starting_count+1) ==  table_model.rowCount()
    qtbot.wait(TestingFlags.TEST_WAIT_SHORT)
Пример #2
0
def test_rowCount(good_data_arrays):
    table_model = CalibrationTableModel()

    for good_data in good_data_arrays:
        table_model.setDataArray(good_data)
        assert table_model.rowCount() == len(good_data)-1