Fix warnings in tests
This commit is contained in:
@@ -441,6 +441,9 @@ def testGuiEditor_ContextMenu(monkeypatch, qtbot, nwGUI, projPath, mockRnd):
|
||||
ctxMenu.deleteLater()
|
||||
|
||||
# Copy Text
|
||||
clipboard = QApplication.clipboard()
|
||||
assert clipboard is not None
|
||||
|
||||
ctxMenu = getMenuForPos(docEditor, 31, True)
|
||||
assert ctxMenu is not None
|
||||
assert docEditor.textCursor().selectedText() == "text"
|
||||
@@ -448,14 +451,14 @@ def testGuiEditor_ContextMenu(monkeypatch, qtbot, nwGUI, projPath, mockRnd):
|
||||
assert actions == [
|
||||
"Cut", "Copy", "Paste", "Select All", "Select Word", "Select Paragraph"
|
||||
]
|
||||
QApplication.clipboard().clear()
|
||||
clipboard.clear()
|
||||
ctxMenu.actions()[1].trigger()
|
||||
assert QApplication.clipboard().text(QClipboard.Mode.Clipboard) == "text"
|
||||
assert clipboard.text(QClipboard.Mode.Clipboard) == "text"
|
||||
|
||||
# Cut Text
|
||||
QApplication.clipboard().clear()
|
||||
clipboard.clear()
|
||||
ctxMenu.actions()[0].trigger()
|
||||
assert QApplication.clipboard().text(QClipboard.Mode.Clipboard) == "text"
|
||||
assert clipboard.text(QClipboard.Mode.Clipboard) == "text"
|
||||
assert "text" not in docEditor.getText()
|
||||
|
||||
# Paste Text
|
||||
@@ -572,7 +575,9 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
# Select/Cut/Copy/Paste/Undo/Redo
|
||||
# ===============================
|
||||
|
||||
QApplication.clipboard().clear()
|
||||
clipboard = QApplication.clipboard()
|
||||
assert clipboard is not None
|
||||
clipboard.clear()
|
||||
|
||||
# Select All
|
||||
assert docEditor.docAction(nwDocAction.SEL_ALL) is True
|
||||
@@ -624,7 +629,7 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
assert newPara[5] == ipsumText[4]
|
||||
assert newPara[6] == ipsumText[2]
|
||||
|
||||
QApplication.clipboard().clear()
|
||||
clipboard.clear()
|
||||
|
||||
# Emphasis/Undo/Redo
|
||||
# ==================
|
||||
|
||||
@@ -91,18 +91,19 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
docViewer.setTextCursor(cursor)
|
||||
docViewer._makeSelection(QTextCursor.SelectionType.WordUnderCursor)
|
||||
|
||||
qClip = QApplication.clipboard()
|
||||
qClip.clear()
|
||||
clipboard = QApplication.clipboard()
|
||||
assert clipboard is not None
|
||||
clipboard.clear()
|
||||
|
||||
# Cut
|
||||
assert docViewer.docAction(nwDocAction.CUT) is True
|
||||
assert qClip.text() == "laoreet"
|
||||
qClip.clear()
|
||||
assert clipboard.text() == "laoreet"
|
||||
clipboard.clear()
|
||||
|
||||
# Copy
|
||||
assert docViewer.docAction(nwDocAction.COPY) is True
|
||||
assert qClip.text() == "laoreet"
|
||||
qClip.clear()
|
||||
assert clipboard.text() == "laoreet"
|
||||
clipboard.clear()
|
||||
|
||||
# Select Paragraph
|
||||
assert docViewer.docAction(nwDocAction.SEL_PARA) is True
|
||||
|
||||
@@ -1148,7 +1148,9 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
def getTransformSubMenu(menu: QMenu) -> list[str]:
|
||||
for action in menu.actions():
|
||||
if action.text() == "Transform ...":
|
||||
return [x.text() for x in action.menu().actions() if x.text()]
|
||||
submenu = action.menu()
|
||||
assert submenu is not None
|
||||
return [x.text() for x in submenu.actions() if x.text()]
|
||||
return []
|
||||
|
||||
# Context Menu on Document File Item
|
||||
|
||||
Reference in New Issue
Block a user