Replace exec_ with exec
This commit is contained in:
+2
-2
@@ -142,7 +142,7 @@ def projPath(fncPath):
|
||||
@pytest.fixture(scope="function")
|
||||
def mockGUI(qtbot, monkeypatch):
|
||||
"""Create a mock instance of novelWriter's main GUI class."""
|
||||
monkeypatch.setattr(QMessageBox, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(QMessageBox, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(QMessageBox, "result", lambda *a: QMessageBox.Yes)
|
||||
gui = MockGuiMain()
|
||||
theme = MockTheme()
|
||||
@@ -154,7 +154,7 @@ def mockGUI(qtbot, monkeypatch):
|
||||
@pytest.fixture(scope="function")
|
||||
def nwGUI(qtbot, monkeypatch, functionFixture):
|
||||
"""Create an instance of the novelWriter GUI."""
|
||||
monkeypatch.setattr(QMessageBox, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(QMessageBox, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(QMessageBox, "result", lambda *a: QMessageBox.Yes)
|
||||
|
||||
nwGUI = main(["--testmode", f"--config={_TMP_CONF}", f"--data={_TMP_CONF}"])
|
||||
|
||||
@@ -72,27 +72,27 @@ def testBaseError_Handler(qtbot, monkeypatch, nwGUI):
|
||||
"""
|
||||
# Normal shutdown
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(NWErrorMessage, "exec_", lambda *a: None)
|
||||
mp.setattr(NWErrorMessage, "exec", lambda *a: None)
|
||||
mp.setattr("PyQt5.QtWidgets.QApplication.exit", lambda *a: None)
|
||||
exceptionHandler(Exception, "Error Message", None) # type: ignore
|
||||
|
||||
# Should not crash when no GUI is found
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(NWErrorMessage, "exec_", lambda *a: None)
|
||||
mp.setattr(NWErrorMessage, "exec", lambda *a: None)
|
||||
mp.setattr("PyQt5.QtWidgets.QApplication.exit", lambda *a: None)
|
||||
mp.setattr("PyQt5.QtWidgets.QApplication.topLevelWidgets", lambda: [])
|
||||
exceptionHandler(Exception, "Error Message", None) # type: ignore
|
||||
|
||||
# Should handle QApplication failing
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(NWErrorMessage, "exec_", lambda *a: None)
|
||||
mp.setattr(NWErrorMessage, "exec", lambda *a: None)
|
||||
mp.setattr("PyQt5.QtWidgets.QApplication.exit", lambda *a: None)
|
||||
mp.setattr("PyQt5.QtWidgets.QApplication.topLevelWidgets", causeException)
|
||||
exceptionHandler(Exception, "Error Message", None) # type: ignore
|
||||
|
||||
# Should handle failing to close main GUI
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(NWErrorMessage, "exec_", lambda *a: None)
|
||||
mp.setattr(NWErrorMessage, "exec", lambda *a: None)
|
||||
mp.setattr("PyQt5.QtWidgets.QApplication.exit", lambda *a: None)
|
||||
mp.setattr(nwGUI, "closeMain", causeException)
|
||||
exceptionHandler(Exception, "Error Message", None) # type: ignore
|
||||
|
||||
@@ -70,7 +70,7 @@ def testBaseInit_Launch(caplog, monkeypatch, fncPath):
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.setApplicationVersion", lambda *a: None)
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.setWindowIcon", lambda *a: None)
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.setOrganizationDomain", lambda *a: None)
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.exec_", lambda *a: 0)
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.exec", lambda *a: 0)
|
||||
with pytest.raises(SystemExit) as ex:
|
||||
main([f"--config={fncPath}", f"--data={fncPath}"])
|
||||
assert ex.value.code == 0
|
||||
@@ -148,7 +148,7 @@ def testBaseInit_Imports(caplog, monkeypatch, fncPath):
|
||||
"""Check import error handling."""
|
||||
monkeypatch.setattr("novelwriter.guimain.GuiMain", MockGuiMain)
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.__init__", lambda *a: None)
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.exec_", lambda *a: 0)
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.exec", lambda *a: 0)
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QErrorMessage.__init__", lambda *a: None)
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QErrorMessage.resize", lambda *a: None)
|
||||
monkeypatch.setattr("PyQt5.QtWidgets.QErrorMessage.showMessage", lambda *a: None)
|
||||
|
||||
@@ -129,7 +129,7 @@ def testBaseSharedData_Projects(monkeypatch, caplog, fncPath):
|
||||
@pytest.mark.base
|
||||
def testBaseSharedData_Alerts(qtbot, monkeypatch, caplog):
|
||||
"""Test SharedData class alert helper functions."""
|
||||
monkeypatch.setattr(QMessageBox, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(QMessageBox, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(QMessageBox, "result", lambda *a: QMessageBox.Yes)
|
||||
|
||||
shared = SharedData()
|
||||
|
||||
@@ -32,7 +32,7 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||
@pytest.mark.gui
|
||||
def testDlgOther_QuoteSelect(qtbot, monkeypatch, nwGUI):
|
||||
"""Test the quote symbols dialog."""
|
||||
monkeypatch.setattr(GuiQuoteSelect, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(GuiQuoteSelect, "exec", lambda *a: None)
|
||||
|
||||
nwQuot = GuiQuoteSelect(nwGUI)
|
||||
nwQuot.show()
|
||||
@@ -68,7 +68,7 @@ def testDlgOther_QuoteSelect(qtbot, monkeypatch, nwGUI):
|
||||
@pytest.mark.gui
|
||||
def testDlgOther_EditLabel(qtbot, monkeypatch):
|
||||
"""Test the label editor dialog."""
|
||||
monkeypatch.setattr(GuiEditLabel, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(GuiEditLabel, "exec", lambda *a: None)
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.Accepted)
|
||||
|
||||
@@ -38,7 +38,7 @@ KEY_DELAY = 1
|
||||
def testDlgPreferences_Main(qtbot, monkeypatch, nwGUI, tstPaths):
|
||||
"""Test the preferences dialog loading."""
|
||||
monkeypatch.setattr(SHARED._spelling, "listDictionaries", lambda: [("en", "English [en]")])
|
||||
monkeypatch.setattr(GuiPreferences, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(GuiPreferences, "exec", lambda *a: None)
|
||||
|
||||
# Load GUI with standard values
|
||||
nwGUI.mainMenu.aPreferences.activate(QAction.ActionEvent.Trigger)
|
||||
|
||||
@@ -42,7 +42,7 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI):
|
||||
test, but are instead tested in the individual tab tests.
|
||||
"""
|
||||
# Block the GUI blocking thread
|
||||
monkeypatch.setattr(GuiProjectSettings, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(GuiProjectSettings, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(GuiProjectSettings, "result", lambda *a: QDialog.Accepted)
|
||||
|
||||
# Check that we cannot open when there is no project
|
||||
|
||||
@@ -38,7 +38,7 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, fncPath, projPath):
|
||||
"""test the word list editor."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
|
||||
monkeypatch.setattr(GuiWordList, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(GuiWordList, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(GuiWordList, "result", lambda *a: QDialog.Accepted)
|
||||
monkeypatch.setattr(GuiWordList, "accept", lambda *a: None)
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ def testGuiEditor_MetaData(qtbot, nwGUI, projPath, mockRnd):
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_ContextMenu(monkeypatch, qtbot, nwGUI, projPath, mockRnd):
|
||||
"""Test the editor context menu."""
|
||||
monkeypatch.setattr(QMenu, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(QMenu, "exec", lambda *a: None)
|
||||
|
||||
buildTestProject(nwGUI, projPath)
|
||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||
|
||||
@@ -146,7 +146,7 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
docViewer.setTextCursor(cursor)
|
||||
docViewer._makeSelection(QTextCursor.WordUnderCursor)
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QMenu, "exec_", mockExec)
|
||||
mp.setattr(QMenu, "exec", mockExec)
|
||||
docViewer._openContextMenu(docViewer.cursorRect().center())
|
||||
assert menuOpened
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ def testGuiMain_ProjectBlocker(nwGUI):
|
||||
@pytest.mark.gui
|
||||
def testGuiMain_Launch(qtbot, monkeypatch, nwGUI, projPath):
|
||||
"""Test the handling of launch tasks."""
|
||||
monkeypatch.setattr(GuiWelcome, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(GuiWelcome, "exec", lambda *a: None)
|
||||
CONFIG.lastNotes = "0x0"
|
||||
buildTestProject(nwGUI, projPath)
|
||||
|
||||
@@ -511,7 +511,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
||||
assert "test" in suggest
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QMenu, "exec_", lambda *a: None)
|
||||
mp.setattr(QMenu, "exec", lambda *a: None)
|
||||
docEditor.setCursorPosition(errPos)
|
||||
docEditor._openContextFromCursor()
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ LANG_DATA = CONFIG.listLanguages(CONFIG.LANG_NW)
|
||||
@pytest.mark.parametrize("language", [a for a, b in LANG_DATA])
|
||||
def testGuiI18n_Localisation(qtbot, monkeypatch, language, nwGUI, projPath):
|
||||
"""Test loading the gui with a specific language."""
|
||||
monkeypatch.setattr(QDialog, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(QMessageBox, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(QDialog, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(QMessageBox, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(QMessageBox, "result", lambda *a: QMessageBox.Yes)
|
||||
|
||||
# Set the test language
|
||||
|
||||
@@ -539,7 +539,7 @@ def testGuiProjTree_MergeDocuments(qtbot, monkeypatch, nwGUI, projPath, mockRnd,
|
||||
mergeData = {}
|
||||
|
||||
monkeypatch.setattr(GuiDocMerge, "__init__", lambda *a: None)
|
||||
monkeypatch.setattr(GuiDocMerge, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(GuiDocMerge, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(GuiDocMerge, "result", lambda *a: QDialog.Accepted)
|
||||
monkeypatch.setattr(GuiDocMerge, "getData", lambda *a: mergeData)
|
||||
|
||||
@@ -640,7 +640,7 @@ def testGuiProjTree_SplitDocument(qtbot, monkeypatch, nwGUI, projPath, mockRnd,
|
||||
splitText = []
|
||||
|
||||
monkeypatch.setattr(GuiDocSplit, "__init__", lambda *a: None)
|
||||
monkeypatch.setattr(GuiDocSplit, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(GuiDocSplit, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(GuiDocSplit, "result", lambda *a: QDialog.Accepted)
|
||||
monkeypatch.setattr(GuiDocSplit, "getData", lambda *a: (splitData, splitText))
|
||||
|
||||
@@ -1162,7 +1162,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
|
||||
# Pop the menu
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QMenu, "exec_", lambda *a: None)
|
||||
mp.setattr(QMenu, "exec", lambda *a: None)
|
||||
projTree.clearSelection()
|
||||
|
||||
# No item under menu
|
||||
|
||||
@@ -60,7 +60,7 @@ def testToolLipsum_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||
nwGUI.docEditor.setCursorLine(3)
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(GuiLipsum, "exec_", lambda *a: None)
|
||||
mp.setattr(GuiLipsum, "exec", lambda *a: None)
|
||||
mp.setattr(GuiLipsum, "lipsumText", "FooBar")
|
||||
nwGUI.mainMenu.aLipsumText.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText() == "### New Scene\n\nFooBar"
|
||||
|
||||
@@ -278,7 +278,7 @@ def testManuscript_Features(monkeypatch, qtbot, nwGUI, projPath, mockRnd):
|
||||
build._changed = True
|
||||
manus.buildList.clearSelection()
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr("novelwriter.tools.manusbuild.GuiManuscriptBuild.exec_", lambda *a: None)
|
||||
mp.setattr("novelwriter.tools.manusbuild.GuiManuscriptBuild.exec", lambda *a: None)
|
||||
|
||||
manus.buildList.setCurrentRow(0)
|
||||
manus.btnBuild.click()
|
||||
@@ -313,7 +313,7 @@ def testManuscript_Print(monkeypatch, qtbot: QtBot, nwGUI: GuiMain, projPath: Pa
|
||||
assert manus.docPreview.toPlainText().strip() != ""
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QPrintPreviewDialog, "exec_", lambda *a: None)
|
||||
mp.setattr(QPrintPreviewDialog, "exec", lambda *a: None)
|
||||
manus.btnPrint.click()
|
||||
for obj in manus.children():
|
||||
if isinstance(obj, QPrintPreviewDialog):
|
||||
|
||||
@@ -70,7 +70,7 @@ def testToolWelcome_Main(qtbot: QtBot, monkeypatch, nwGUI, fncPath):
|
||||
@pytest.mark.gui
|
||||
def testToolWelcome_Open(qtbot: QtBot, monkeypatch, nwGUI, fncPath):
|
||||
"""Test the open tab in the Welcome window."""
|
||||
monkeypatch.setattr(QMenu, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(QMenu, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(QMenu, "deleteLater", lambda *a: None)
|
||||
|
||||
CONFIG.recentProjects.update("/stuff/project_one", "Project One", 12345, 1690000000)
|
||||
|
||||
Reference in New Issue
Block a user