def test_qtbug35861(qtbot): """This test will detect if upstream QTBUG-35861 is fixed. If that happens, then the workarounds for spyder-ide/spyder#12663 can be removed. Such a fix would probably only happen in the most recent Qt version however... See also https://bugreports.qt.io/browse/QTBUG-35861 """ widget = QTextEdit() qtbot.addWidget(widget) widget.show() cursor = widget.textCursor() cursor.setPosition(0) # Build the text from a single character since a non-fixed width # font is used by default. cursor.insertText("0000000000\n"*5) expected_column = 5 cursor.setPosition(expected_column) widget.setTextCursor(cursor) assert widget.textCursor().columnNumber() == expected_column for line in range(4): qtbot.keyClick(widget, Qt.Key_Backspace) assert widget.textCursor().columnNumber() == (expected_column - 1) qtbot.keyClick(widget, Qt.Key_Down) assert widget.textCursor().columnNumber() == expected_column for line in range(4): qtbot.keyClick(widget, Qt.Key_Backspace) assert widget.textCursor().columnNumber() == (expected_column - 1) qtbot.keyClick(widget, Qt.Key_Up) assert widget.textCursor().columnNumber() == expected_column
def test_array_table_matrix_empty(botarray): # analysis:ignore qtbot, dialog, widget = botarray qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.NoModifier) value = dialog.text() assert value == ''
def test_array_table_array_spaces_in_item(botarray): # analysis:ignore qtbot, dialog, widget = botarray qtbot.keyClicks(widget, ' ') qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_2) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_Backtab) qtbot.keyClick(widget, Qt.Key_3) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_5) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_6) qtbot.keyClick(widget, Qt.Key_Tab) # Hack: in the tests the selected cell is wrong qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.NoModifier) value = dialog.text() assert value == 'np.array([[0, 2, 3],\n [0, 5, 6]])'
def test_array_table_matrix(botarray): # analysis:ignore qtbot, dialog, widget = botarray qtbot.keyClick(widget, Qt.Key_1) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_2) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick( widget, Qt.Key_Backtab) # Hack: in the tests the selected cell is wrong qtbot.keyClick(widget, Qt.Key_3) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_4) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_5) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_6) qtbot.keyClick(widget, Qt.Key_Tab) # Hack: in the tests the selected cell is wrong qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.ControlModifier) value = dialog.text() assert value == 'np.matrix([[1, 2, 3],\n [4, 5, 6]])'
def test_array_table_array(botarray): qtbot, dialog, widget = botarray qtbot.keyClick(widget, Qt.Key_1) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_2) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick( widget, Qt.Key_Backtab) # Hack: in the tests the selected cell is wrong qtbot.keyClick(widget, Qt.Key_3) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_4) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_5) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_6) qtbot.keyClick(widget, Qt.Key_Tab) # Hack: in the tests the selected cell is wrong qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.NoModifier) value = dialog.text() assert value == 'np.array([[1, 2, 3],\n [4, 5, 6]])'
def test_array_table_array(botarray): qtbot, dialog, widget = botarray qtbot.keyClick(widget, Qt.Key_1) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_2) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_Backtab) # Hack: in the tests the selected cell is wrong qtbot.keyClick(widget, Qt.Key_3) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_4) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_5) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_6) qtbot.keyClick(widget, Qt.Key_Tab) # Hack: in the tests the selected cell is wrong qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.NoModifier) value = dialog.text() assert value == 'np.array([[1, 2, 3],\n [4, 5, 6]])'
def test_array_table_matrix(botarray): # analysis:ignore qtbot, dialog, widget = botarray qtbot.keyClick(widget, Qt.Key_1) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_2) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_Backtab) # Hack: in the tests the selected cell is wrong qtbot.keyClick(widget, Qt.Key_3) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_4) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_5) qtbot.keyClick(widget, Qt.Key_Tab) qtbot.keyClick(widget, Qt.Key_6) qtbot.keyClick(widget, Qt.Key_Tab) # Hack: in the tests the selected cell is wrong qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.ControlModifier) value = dialog.text() assert value == 'np.matrix([[1, 2, 3],\n [4, 5, 6]])'