diff --git a/tests/conftest.py b/tests/conftest.py
index 40725923..12842add 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -162,7 +162,11 @@ def mockGUI(monkeypatch, tmpConf):
def nwGUI(qtbot, monkeypatch, fncDir, fncConf):
"""Create an instance of the novelWriter GUI.
"""
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
+ monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Ok)
+ monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Ok)
+ monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Ok)
+ monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
+
monkeypatch.setattr("novelwriter.CONFIG", fncConf)
nwGUI = novelwriter.main(["--testmode", "--config=%s" % fncDir, "--data=%s" % fncDir])
qtbot.addWidget(nwGUI)
diff --git a/tests/test_dialogs/test_dlg_about.py b/tests/test_dialogs/test_dlg_about.py
index 80a6ca06..63de9039 100644
--- a/tests/test_dialogs/test_dlg_about.py
+++ b/tests/test_dialogs/test_dlg_about.py
@@ -29,12 +29,9 @@ from novelwriter.dialogs.about import GuiAbout
@pytest.mark.gui
-def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
+def testDlgAbout_NWDialog(qtbot, nwGUI):
"""Test the novelWriter about dialogs.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
-
# NW About
nwGUI.mainTheme.themeName = "A Theme"
nwGUI.mainTheme.themeAuthor = "An Author"
@@ -74,8 +71,6 @@ def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
def testDlgAbout_QtDialog(monkeypatch, nwGUI):
"""Test the Qt about dialogs.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(QMessageBox, "aboutQt", lambda *a, **k: None)
# Open About
diff --git a/tests/test_dialogs/test_dlg_dialogs.py b/tests/test_dialogs/test_dlg_dialogs.py
index 9afcf410..772554ea 100644
--- a/tests/test_dialogs/test_dlg_dialogs.py
+++ b/tests/test_dialogs/test_dlg_dialogs.py
@@ -22,7 +22,7 @@ along with this program. If not, see .
import pytest
from PyQt5.QtCore import QItemSelectionModel
-from PyQt5.QtWidgets import QAction, QListWidgetItem, QDialog, QMessageBox
+from PyQt5.QtWidgets import QAction, QListWidgetItem, QDialog
from novelwriter.dialogs.quotes import GuiQuoteSelect
from novelwriter.dialogs.updates import GuiUpdates
@@ -30,12 +30,9 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
@pytest.mark.gui
-def testDlgOther_QuoteSelect(qtbot, monkeypatch, nwGUI):
+def testDlgOther_QuoteSelect(qtbot, nwGUI):
"""Test the quote symbols dialog.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
-
nwQuot = GuiQuoteSelect(nwGUI)
nwQuot.show()
@@ -52,7 +49,7 @@ def testDlgOther_QuoteSelect(qtbot, monkeypatch, nwGUI):
assert nwQuot.result() == QDialog.Accepted
assert nwQuot.selectedQuote == lastItem
- # qtbot.stopForInteraction()
+ # qtbot.stop()
nwQuot._doReject()
nwQuot.close()
@@ -63,9 +60,6 @@ def testDlgOther_QuoteSelect(qtbot, monkeypatch, nwGUI):
def testDlgOther_Updates(qtbot, monkeypatch, nwGUI):
"""Test the check for updates dialog.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
-
nwUpdate = GuiUpdates(nwGUI)
nwUpdate.show()
@@ -95,7 +89,7 @@ def testDlgOther_Updates(qtbot, monkeypatch, nwGUI):
# Trigger from Menu
nwGUI.mainMenu.aUpdates.activate(QAction.Trigger)
- # qtbot.stopForInteraction()
+ # qtbot.stop()
nwUpdate._doClose()
# END Test testDlgOther_Updates
diff --git a/tests/test_dialogs/test_dlg_docmerge.py b/tests/test_dialogs/test_dlg_docmerge.py
index 4b86fa78..1cf4768c 100644
--- a/tests/test_dialogs/test_dlg_docmerge.py
+++ b/tests/test_dialogs/test_dlg_docmerge.py
@@ -24,19 +24,14 @@ import pytest
from tools import buildTestProject, C
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QMessageBox
from novelwriter.dialogs.docmerge import GuiDocMerge
@pytest.mark.gui
-def testDlgMerge_Main(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
+def testDlgMerge_Main(qtbot, nwGUI, fncProj, mockRnd):
"""Test the merge documents tool.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Ok)
-
# Create a new project
buildTestProject(nwGUI, fncProj)
diff --git a/tests/test_dialogs/test_dlg_docsplit.py b/tests/test_dialogs/test_dlg_docsplit.py
index 4689f76d..05092c67 100644
--- a/tests/test_dialogs/test_dlg_docsplit.py
+++ b/tests/test_dialogs/test_dlg_docsplit.py
@@ -23,8 +23,6 @@ import pytest
from tools import C, buildTestProject
-from PyQt5.QtWidgets import QMessageBox
-
from novelwriter.dialogs.docsplit import GuiDocSplit
from novelwriter.dialogs.editlabel import GuiEditLabel
@@ -33,9 +31,6 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
"""Test the split document tool.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Ok)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
# Create a new project
diff --git a/tests/test_dialogs/test_dlg_preferences.py b/tests/test_dialogs/test_dlg_preferences.py
index 22461751..4b077699 100644
--- a/tests/test_dialogs/test_dlg_preferences.py
+++ b/tests/test_dialogs/test_dlg_preferences.py
@@ -35,9 +35,7 @@ from novelwriter.config import Config
from novelwriter.dialogs.quotes import GuiQuoteSelect
from novelwriter.dialogs.preferences import GuiPreferences
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
+KEY_DELAY = 1
@pytest.mark.gui
@@ -63,7 +61,6 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
nwGUI = novelwriter.main(["--testmode", "--config=%s" % fncDir, "--data=%s" % fncDir])
qtbot.addWidget(nwGUI)
nwGUI.show()
- qtbot.wait(stepDelay)
theConf = nwGUI.mainConf
assert theConf.confPath == fncDir
@@ -81,21 +78,21 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
assert nwPrefs.mainConf.confPath == fncDir
# General Settings
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabGeneral = nwPrefs.tabGeneral
nwPrefs._tabBox.setCurrentWidget(tabGeneral)
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert tabGeneral.showFullPath.isChecked()
qtbot.mouseClick(tabGeneral.showFullPath, Qt.LeftButton)
assert not tabGeneral.showFullPath.isChecked()
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert not tabGeneral.hideVScroll.isChecked()
qtbot.mouseClick(tabGeneral.hideVScroll, Qt.LeftButton)
assert tabGeneral.hideVScroll.isChecked()
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert not tabGeneral.hideHScroll.isChecked()
qtbot.mouseClick(tabGeneral.hideHScroll, Qt.LeftButton)
assert tabGeneral.hideHScroll.isChecked()
@@ -104,21 +101,21 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
monkeypatch.setattr(QFontDialog, "getFont", lambda font, obj: (font, True))
qtbot.mouseClick(tabGeneral.fontButton, Qt.LeftButton)
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabGeneral.guiFontSize.setValue(12)
# Projects Settings
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabProjects = nwPrefs.tabProjects
nwPrefs._tabBox.setCurrentWidget(tabProjects)
tabProjects.backupPath = "no/where"
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert not tabProjects.backupOnClose.isChecked()
qtbot.mouseClick(tabProjects.backupOnClose, Qt.LeftButton)
assert tabProjects.backupOnClose.isChecked()
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# Check Browse button
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *a, **k: "")
@@ -126,99 +123,99 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *a, **k: "some/dir")
qtbot.mouseClick(tabProjects.backupGetPath, Qt.LeftButton)
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabProjects.autoSaveDoc.setValue(20)
tabProjects.autoSaveProj.setValue(40)
# Document Settings
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabDocs = nwPrefs.tabDocs
nwPrefs._tabBox.setCurrentWidget(tabDocs)
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
qtbot.mouseClick(tabDocs.fontButton, Qt.LeftButton)
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabDocs.textSize.setValue(13)
tabDocs.textWidth.setValue(700)
tabDocs.focusWidth.setValue(900)
tabDocs.textMargin.setValue(45)
tabDocs.tabWidth.setValue(45)
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert not tabDocs.hideFocusFooter.isChecked()
qtbot.mouseClick(tabDocs.hideFocusFooter, Qt.LeftButton)
assert tabDocs.hideFocusFooter.isChecked()
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert not tabDocs.doJustify.isChecked()
qtbot.mouseClick(tabDocs.doJustify, Qt.LeftButton)
assert tabDocs.doJustify.isChecked()
# Editor Settings
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabEditor = nwPrefs.tabEditor
nwPrefs._tabBox.setCurrentWidget(tabEditor)
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert not tabEditor.showTabsNSpaces.isChecked()
qtbot.mouseClick(tabEditor.showTabsNSpaces, Qt.LeftButton)
assert tabEditor.showTabsNSpaces.isChecked()
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert not tabEditor.showLineEndings.isChecked()
qtbot.mouseClick(tabEditor.showLineEndings, Qt.LeftButton)
assert tabEditor.showLineEndings.isChecked()
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert not tabEditor.autoScroll.isChecked()
qtbot.mouseClick(tabEditor.autoScroll, Qt.LeftButton)
assert tabEditor.autoScroll.isChecked()
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabEditor.scrollPastEnd.setValue(0)
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabEditor.bigDocLimit.setValue(500)
# Syntax Settings
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabSyntax = nwPrefs.tabSyntax
nwPrefs._tabBox.setCurrentWidget(tabSyntax)
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert tabSyntax.highlightQuotes.isChecked()
qtbot.mouseClick(tabSyntax.highlightQuotes, Qt.LeftButton)
assert not tabSyntax.highlightQuotes.isChecked()
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert tabSyntax.highlightEmph.isChecked()
qtbot.mouseClick(tabSyntax.highlightEmph, Qt.LeftButton)
assert not tabSyntax.highlightEmph.isChecked()
# Automation Settings
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabAuto = nwPrefs.tabAuto
nwPrefs._tabBox.setCurrentWidget(tabAuto)
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert tabAuto.autoSelect.isChecked()
qtbot.mouseClick(tabAuto.autoSelect, Qt.LeftButton)
assert not tabAuto.autoSelect.isChecked()
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert tabAuto.doReplace.isChecked()
qtbot.mouseClick(tabAuto.doReplace, Qt.LeftButton)
assert not tabAuto.doReplace.isChecked()
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
assert not tabAuto.doReplaceSQuote.isEnabled()
assert not tabAuto.doReplaceDQuote.isEnabled()
assert not tabAuto.doReplaceDash.isEnabled()
assert not tabAuto.doReplaceDots.isEnabled()
# Quotation Style
- qtbot.wait(keyDelay)
+ qtbot.wait(KEY_DELAY)
tabQuote = nwPrefs.tabQuote
nwPrefs._tabBox.setCurrentWidget(tabQuote)
@@ -249,6 +246,6 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
novelwriter.CONFIG = origConf
nwGUI.closeMain()
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testDlgPreferences_Main
diff --git a/tests/test_dialogs/test_dlg_projdetails.py b/tests/test_dialogs/test_dlg_projdetails.py
index b2952ad6..84360d11 100644
--- a/tests/test_dialogs/test_dlg_projdetails.py
+++ b/tests/test_dialogs/test_dlg_projdetails.py
@@ -23,25 +23,15 @@ import pytest
from tools import getGuiItem
-from PyQt5.QtWidgets import QAction, QMessageBox
+from PyQt5.QtWidgets import QAction
from novelwriter.dialogs.projdetails import GuiProjectDetails
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
-
@pytest.mark.gui
-def testDlgProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
+def testDlgProjDetails_Dialog(qtbot, nwGUI, nwLipsum):
"""Test the project details dialog.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Create a project to work on
assert nwGUI.openProject(nwLipsum)
assert nwGUI.rebuildIndex(beQuiet=True)
@@ -54,7 +44,6 @@ def testDlgProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
projDet = getGuiItem("GuiProjectDetails")
assert isinstance(projDet, GuiProjectDetails)
- qtbot.wait(stepDelay)
# Overview Page
# =============
@@ -105,7 +94,7 @@ def testDlgProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
assert tocTree.topLevelItem(i).text(tocTab.C_PAGES) == thePages[i]
assert tocTree.topLevelItem(i).text(tocTab.C_PAGE) == thePage[i]
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# Clean Up
projDet._doClose()
diff --git a/tests/test_dialogs/test_dlg_projload.py b/tests/test_dialogs/test_dlg_projload.py
index 5916d185..6e81ffe2 100644
--- a/tests/test_dialogs/test_dlg_projload.py
+++ b/tests/test_dialogs/test_dlg_projload.py
@@ -26,29 +26,19 @@ from tools import getGuiItem
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
- QDialogButtonBox, QTreeWidgetItem, QDialog, QAction, QFileDialog,
- QMessageBox
+ QDialogButtonBox, QTreeWidgetItem, QDialog, QAction, QFileDialog
)
from novelwriter.dialogs.projload import GuiProjectLoad
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
-
@pytest.mark.gui
def testDlgLoadProject_Main(qtbot, monkeypatch, nwGUI, nwMinimal):
"""Test the load project wizard.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
-
assert nwGUI.openProject(nwMinimal)
assert nwGUI.closeProject()
- qtbot.wait(stepDelay)
monkeypatch.setattr(GuiProjectLoad, "exec_", lambda *a: None)
monkeypatch.setattr(GuiProjectLoad, "result", lambda *a: QDialog.Accepted)
nwGUI.mainMenu.aOpenProject.activate(QAction.Trigger)
@@ -58,22 +48,18 @@ def testDlgLoadProject_Main(qtbot, monkeypatch, nwGUI, nwMinimal):
assert isinstance(nwLoad, GuiProjectLoad)
nwLoad.show()
- qtbot.wait(stepDelay)
recentCount = nwLoad.listBox.topLevelItemCount()
assert recentCount > 0
- qtbot.wait(stepDelay)
selItem = nwLoad.listBox.topLevelItem(0)
selPath = selItem.data(nwLoad.C_NAME, Qt.UserRole)
assert isinstance(selItem, QTreeWidgetItem)
- qtbot.wait(stepDelay)
nwLoad.selPath.setText("")
nwLoad.listBox.setCurrentItem(selItem)
nwLoad._doSelectRecent()
assert nwLoad.selPath.text() == selPath
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwLoad.buttonBox.button(QDialogButtonBox.Open), Qt.LeftButton)
assert nwLoad.openPath == selPath
assert nwLoad.openState == nwLoad.OPEN_STATE
@@ -81,27 +67,22 @@ def testDlgLoadProject_Main(qtbot, monkeypatch, nwGUI, nwMinimal):
# Just create a new project load from scratch for the rest of the test
del nwLoad
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aOpenProject.activate(QAction.Trigger)
qtbot.waitUntil(lambda: getGuiItem("GuiProjectLoad") is not None, timeout=1000)
- qtbot.wait(stepDelay)
nwLoad = getGuiItem("GuiProjectLoad")
assert isinstance(nwLoad, GuiProjectLoad)
nwLoad.show()
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwLoad.buttonBox.button(QDialogButtonBox.Cancel), Qt.LeftButton)
assert nwLoad.openPath is None
assert nwLoad.openState == nwLoad.NONE_STATE
- qtbot.wait(stepDelay)
nwLoad.show()
qtbot.mouseClick(nwLoad.newButton, Qt.LeftButton)
assert nwLoad.openPath is None
assert nwLoad.openState == nwLoad.NEW_STATE
- qtbot.wait(stepDelay)
nwLoad.show()
nwLoad._doDeleteRecent()
assert nwLoad.listBox.topLevelItemCount() == recentCount - 1
@@ -113,6 +94,6 @@ def testDlgLoadProject_Main(qtbot, monkeypatch, nwGUI, nwMinimal):
assert nwLoad.openState == nwLoad.OPEN_STATE
nwLoad.close()
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testDlgLoadProject_Main
diff --git a/tests/test_dialogs/test_dlg_projsettings.py b/tests/test_dialogs/test_dlg_projsettings.py
index 48e896bf..bb38f317 100644
--- a/tests/test_dialogs/test_dlg_projsettings.py
+++ b/tests/test_dialogs/test_dlg_projsettings.py
@@ -26,14 +26,12 @@ from tools import C, getGuiItem, buildTestProject
from PyQt5.QtGui import QColor
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QDialog, QAction, QMessageBox, QColorDialog
+from PyQt5.QtWidgets import QDialog, QAction, QColorDialog
from novelwriter.dialogs.editlabel import GuiEditLabel
from novelwriter.dialogs.projsettings import GuiProjectSettings
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
+KEY_DELAY = 1
@pytest.mark.gui
@@ -41,10 +39,6 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI):
"""Test the main dialog class. Saving settings is not tested in this
test, but are instead tested in the individual tab tests.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Block the GUI blocking thread
monkeypatch.setattr(GuiProjectSettings, "exec_", lambda *a: None)
monkeypatch.setattr(GuiProjectSettings, "result", lambda *a: QDialog.Accepted)
@@ -91,10 +85,6 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI):
def testDlgProjSettings_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd):
"""Test the main tab of the project settings dialog.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Mock components
monkeypatch.setattr(nwGUI.docEditor.spEnchant, "listDictionaries", lambda: [("en", "none")])
@@ -125,23 +115,21 @@ def testDlgProjSettings_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd
assert tabMain.spellLang.currentData() == "en"
assert tabMain.doBackup.isChecked() is False
- qtbot.wait(stepDelay)
tabMain.editName.setText("")
for c in "Project Name":
- qtbot.keyClick(tabMain.editName, c, delay=typeDelay)
+ qtbot.keyClick(tabMain.editName, c, delay=KEY_DELAY)
tabMain.editTitle.setText("")
for c in "Project Title":
- qtbot.keyClick(tabMain.editTitle, c, delay=typeDelay)
+ qtbot.keyClick(tabMain.editTitle, c, delay=KEY_DELAY)
tabMain.editAuthors.clear()
for c in "Jane Doe":
- qtbot.keyClick(tabMain.editAuthors, c, delay=typeDelay)
- qtbot.keyClick(tabMain.editAuthors, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(tabMain.editAuthors, c, delay=KEY_DELAY)
+ qtbot.keyClick(tabMain.editAuthors, Qt.Key_Return, delay=KEY_DELAY)
for c in "John Doh":
- qtbot.keyClick(tabMain.editAuthors, c, delay=typeDelay)
- qtbot.keyClick(tabMain.editAuthors, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(tabMain.editAuthors, c, delay=KEY_DELAY)
+ qtbot.keyClick(tabMain.editAuthors, Qt.Key_Return, delay=KEY_DELAY)
- qtbot.wait(stepDelay)
assert tabMain.editName.text() == "Project Name"
assert tabMain.editTitle.text() == "Project Title"
assert tabMain.editAuthors.toPlainText() == "Jane Doe\nJohn Doh\n"
@@ -164,9 +152,6 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, fncDir, fncProj,
"""Test the status and importance tabs of the project settings
dialog.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
# Mock components
@@ -230,9 +215,9 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, fncDir, fncProj,
qtbot.mouseClick(tabStatus.addButton, Qt.LeftButton)
tabStatus.listBox.setCurrentItem(tabStatus.listBox.topLevelItem(3))
for _ in range(8):
- qtbot.keyClick(tabStatus.editName, Qt.Key_Backspace, delay=typeDelay)
+ qtbot.keyClick(tabStatus.editName, Qt.Key_Backspace, delay=KEY_DELAY)
for c in "Final":
- qtbot.keyClick(tabStatus.editName, c, delay=typeDelay)
+ qtbot.keyClick(tabStatus.editName, c, delay=KEY_DELAY)
qtbot.mouseClick(tabStatus.colButton, Qt.LeftButton)
qtbot.mouseClick(tabStatus.saveButton, Qt.LeftButton)
assert tabStatus.listBox.topLevelItemCount() == 4
@@ -310,9 +295,9 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, fncDir, fncProj,
tabImport.listBox.clearSelection()
tabImport.listBox.setCurrentItem(tabImport.listBox.topLevelItem(3))
for _ in range(8):
- qtbot.keyClick(tabImport.editName, Qt.Key_Backspace, delay=typeDelay)
+ qtbot.keyClick(tabImport.editName, Qt.Key_Backspace, delay=KEY_DELAY)
for c in "Final":
- qtbot.keyClick(tabImport.editName, c, delay=typeDelay)
+ qtbot.keyClick(tabImport.editName, c, delay=KEY_DELAY)
qtbot.mouseClick(tabImport.colButton, Qt.LeftButton)
qtbot.mouseClick(tabImport.saveButton, Qt.LeftButton)
assert tabImport.listBox.topLevelItemCount() == 4
@@ -368,9 +353,6 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, fncDir, fncProj,
def testDlgProjSettings_Replace(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd):
"""Test the auto-replace tab of the project settings dialog.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
# Mock components
@@ -419,10 +401,10 @@ def testDlgProjSettings_Replace(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mock
tabReplace.listBox.setCurrentItem(tabReplace.listBox.topLevelItem(2))
tabReplace.editKey.setText("")
for c in "Th is ":
- qtbot.keyClick(tabReplace.editKey, c, delay=typeDelay)
+ qtbot.keyClick(tabReplace.editKey, c, delay=KEY_DELAY)
tabReplace.editValue.setText("")
for c in "With This Stuff ":
- qtbot.keyClick(tabReplace.editValue, c, delay=typeDelay)
+ qtbot.keyClick(tabReplace.editValue, c, delay=KEY_DELAY)
qtbot.mouseClick(tabReplace.saveButton, Qt.LeftButton)
assert tabReplace.listBox.topLevelItem(2).text(0) == ""
assert tabReplace.listBox.topLevelItem(2).text(1) == "With This Stuff "
diff --git a/tests/test_dialogs/test_dlg_wordlist.py b/tests/test_dialogs/test_dlg_wordlist.py
index 994fb407..24d61157 100644
--- a/tests/test_dialogs/test_dlg_wordlist.py
+++ b/tests/test_dialogs/test_dlg_wordlist.py
@@ -23,7 +23,7 @@ import os
import pytest
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QDialog, QMessageBox, QAction
+from PyQt5.QtWidgets import QDialog, QAction
from tools import writeFile, readFile, getGuiItem
from mock import causeOSError
@@ -31,25 +31,17 @@ from mock import causeOSError
from novelwriter.constants import nwFiles
from novelwriter.dialogs.wordlist import GuiWordList
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
-
@pytest.mark.gui
def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, nwMinimal):
"""test the word list editor.
"""
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiWordList, "exec_", lambda *a: None)
monkeypatch.setattr(GuiWordList, "result", lambda *a: QDialog.Accepted)
monkeypatch.setattr(GuiWordList, "accept", lambda *a: None)
# Open project
nwGUI.openProject(nwMinimal)
- qtbot.wait(stepDelay)
dictFile = os.path.join(nwMinimal, "meta", nwFiles.PROJ_DICT)
# Load the dialog
@@ -59,7 +51,6 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, nwMinimal):
wList = getGuiItem("GuiWordList")
assert isinstance(wList, GuiWordList)
wList.show()
- qtbot.wait(stepDelay)
# List should be blank
assert wList.listBox.count() == 0
@@ -73,7 +64,6 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, nwMinimal):
"word_f\n"
"word_b\n"
))
- qtbot.wait(stepDelay)
assert wList._loadWordList()
# Check that the content was loaded
@@ -130,7 +120,7 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, nwMinimal):
monkeypatch.setattr("builtins.open", causeOSError)
assert not wList._doSave()
- # qtbot.stopForInteraction()
+ # qtbot.stop()
wList._doClose()
# END Test testDlgWordList_Dialog
diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py
index 68f02c71..e2ba77ae 100644
--- a/tests/test_gui/test_gui_doceditor.py
+++ b/tests/test_gui/test_gui_doceditor.py
@@ -25,33 +25,26 @@ from mock import causeOSError
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QTextBlock, QTextCursor, QTextOption
-from PyQt5.QtWidgets import QAction, QMessageBox, qApp
+from PyQt5.QtWidgets import QAction, qApp
from novelwriter.enum import nwDocAction, nwDocInsert, nwItemLayout
from novelwriter.constants import nwKeyWords, nwUnicode
from novelwriter.core.index import countWords
from novelwriter.gui.doceditor import GuiDocEditor
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
+KEY_DELAY = 1
@pytest.mark.gui
-def testGuiEditor_Init(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
+def testGuiEditor_Init(qtbot, nwGUI, nwMinimal, ipsumText):
"""Test initialising the editor.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
-
# Open project
assert nwGUI.openProject(nwMinimal)
assert nwGUI.openDocument("8c659a11cd429")
nwGUI.docEditor.setText("### Lorem Ipsum\n\n%s" % ipsumText[0])
assert nwGUI.saveDocument()
- qtbot.wait(stepDelay)
# Check Defaults
qDoc = nwGUI.docEditor.document()
@@ -80,7 +73,7 @@ def testGuiEditor_Init(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
assert nwGUI.docEditor.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
assert nwGUI.docEditor._typPadChar == nwUnicode.U_THNBSP
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiEditor_Init
@@ -89,10 +82,6 @@ def testGuiEditor_Init(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ipsumText):
"""Test loading text into the editor.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Open project
sHandle = "8c659a11cd429"
assert nwGUI.openProject(nwMinimal) is True
@@ -102,7 +91,6 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ipsumTe
nwGUI.docEditor.replaceText(longText)
assert nwGUI.saveDocument() is True
assert nwGUI.closeDocument() is True
- qtbot.wait(stepDelay)
# Load Text
# =========
@@ -142,7 +130,7 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ipsumTe
assert nwGUI.docEditor.loadText(sHandle) is True
assert nwGUI.docEditor.toPlainText() == ""
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiEditor_LoadText
@@ -151,15 +139,10 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ipsumTe
def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ipsumText):
"""Test saving text from the editor.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Open project
sHandle = "8c659a11cd429"
assert nwGUI.openProject(nwMinimal) is True
assert nwGUI.openDocument(sHandle) is True
- qtbot.wait(stepDelay)
# Save Text
# =========
@@ -193,24 +176,19 @@ def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ipsumTe
# Regular save
assert nwGUI.docEditor.saveText() is True
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiEditor_SaveText
@pytest.mark.gui
-def testGuiEditor_MetaData(qtbot, monkeypatch, nwGUI, nwMinimal):
+def testGuiEditor_MetaData(qtbot, nwGUI, nwMinimal):
"""Test extracting various meta data and other values.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Open project
sHandle = "8c659a11cd429"
assert nwGUI.openProject(nwMinimal) is True
assert nwGUI.openDocument(sHandle) is True
- qtbot.wait(stepDelay)
# Get Text
# This should replace line and paragraph separators, but preserve
@@ -253,21 +231,16 @@ def testGuiEditor_MetaData(qtbot, monkeypatch, nwGUI, nwMinimal):
@pytest.mark.gui
-def testGuiEditor_Actions(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
+def testGuiEditor_Actions(qtbot, nwGUI, nwMinimal, ipsumText):
"""Test the document actions. This is not an extensive test of the
action features, just that the actions are actually called. The
various action features are tested when their respective functions
are tested.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Open project
sHandle = "8c659a11cd429"
assert nwGUI.openProject(nwMinimal) is True
assert nwGUI.openDocument(sHandle) is True
- qtbot.wait(stepDelay)
theText = "### A Scene\n\n%s" % "\n\n".join(ipsumText)
assert nwGUI.docEditor.replaceText(theText) is True
@@ -487,7 +460,7 @@ def testGuiEditor_Actions(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
# Unknown Action
assert nwGUI.docEditor.docAction(nwDocAction.NO_ACTION) is False
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiEditor_Actions
@@ -496,15 +469,10 @@ def testGuiEditor_Actions(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
"""Test the document insert functions.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Open project
sHandle = "8c659a11cd429"
assert nwGUI.openProject(nwMinimal) is True
assert nwGUI.openDocument(sHandle) is True
- qtbot.wait(stepDelay)
theText = "### A Scene\n\n%s" % "\n\n".join(ipsumText)
assert nwGUI.docEditor.replaceText(theText) is True
@@ -577,7 +545,7 @@ def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
"\n\n\n", "\n\n@pov: Jane\n@char: John\n\n", 1
)
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiEditor_Insert
@@ -586,15 +554,10 @@ def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
def testGuiEditor_TextManipulation(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
"""Test the text manipulation functions.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Open project
sHandle = "8c659a11cd429"
assert nwGUI.openProject(nwMinimal) is True
assert nwGUI.openDocument(sHandle) is True
- qtbot.wait(stepDelay)
theText = "### A Scene\n\n%s" % "\n\n".join(ipsumText)
assert nwGUI.docEditor.replaceText(theText) is True
@@ -791,7 +754,7 @@ def testGuiEditor_TextManipulation(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumTe
assert newPara[6] == twoBits[4]
assert newPara[7] == " ".join(twoBits[5:])
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiEditor_TextManipulation
@@ -800,15 +763,10 @@ def testGuiEditor_TextManipulation(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumTe
def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
"""Test the block formatting function.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Open project
sHandle = "8c659a11cd429"
assert nwGUI.openProject(nwMinimal) is True
assert nwGUI.openDocument(sHandle) is True
- qtbot.wait(stepDelay)
theText = "### A Scene\n\n%s" % "\n\n".join(ipsumText)
assert nwGUI.docEditor.replaceText(theText) is True
@@ -1115,24 +1073,19 @@ def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumTex
assert nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_COM) is True
assert nwGUI.docEditor.getText() == "#### Title\n\n% The Text\n\n"
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiEditor_BlockFormatting
@pytest.mark.gui
-def testGuiEditor_Tags(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
+def testGuiEditor_Tags(qtbot, nwGUI, nwMinimal, ipsumText):
"""Test the document editor tags functionality.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Open project
sHandle = "8c659a11cd429"
assert nwGUI.openProject(nwMinimal) is True
assert nwGUI.openDocument(sHandle) is True
- qtbot.wait(stepDelay)
# Create Scene
theText = "### A Scene\n\n@char: Jane, John\n\n" + ipsumText[0] + "\n\n"
@@ -1181,7 +1134,7 @@ def testGuiEditor_Tags(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
assert nwGUI.closeDocViewer() is True
assert nwGUI.docViewer._docHandle is None
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiEditor_Tags
@@ -1190,10 +1143,6 @@ def testGuiEditor_Tags(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
"""Test saving text from the editor.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
class MockThreadPool:
def __init__(self):
@@ -1226,7 +1175,6 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
nwGUI.theProject.tree[sHandle]._initCount = 0 # Clear item's count
nwGUI.theProject.tree[sHandle]._wordCount = 0 # Clear item's count
assert nwGUI.openDocument(sHandle) is True
- qtbot.wait(stepDelay)
theText = "\n\n".join(ipsumText)
cC, wC, pC = countWords(theText)
@@ -1249,7 +1197,6 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
nwGUI.docEditor.wCounterDoc.run()
# nwGUI.docEditor._updateDocCounts(cC, wC, pC)
- qtbot.wait(stepDelay)
assert nwGUI.theProject.tree[sHandle]._charCount == cC
assert nwGUI.theProject.tree[sHandle]._wordCount == wC
assert nwGUI.theProject.tree[sHandle]._paraCount == pC
@@ -1258,7 +1205,6 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
# Select all text
assert nwGUI.docEditor.docFooter._docSelection is False
nwGUI.docEditor.docAction(nwDocAction.SEL_ALL)
- qtbot.wait(stepDelay)
assert nwGUI.docEditor.docFooter._docSelection is True
# Run the selection word counter
@@ -1267,10 +1213,9 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
nwGUI.docEditor.wCounterSel.run()
# nwGUI.docEditor._updateSelCounts(cC, wC, pC)
- qtbot.wait(stepDelay)
assert nwGUI.docEditor.docFooter.wordsText.text() == f"Words: {wC} selected"
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiEditor_WordCounters
@@ -1279,14 +1224,11 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText):
def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, nwLipsum):
"""Test the document editor search functionality.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True)
assert nwGUI.openProject(nwLipsum) is True
assert nwGUI.openDocument("4c4f28287af27") is True
origText = nwGUI.docEditor.getText()
- qtbot.wait(stepDelay)
# Select the Word "est"
nwGUI.docEditor.setCursorPosition(630)
@@ -1301,11 +1243,11 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, nwLipsum):
# Find next by enter key
monkeypatch.setattr(nwGUI.docEditor.docSearch.searchBox, "hasFocus", lambda: True)
- qtbot.keyClick(nwGUI.docEditor.docSearch.searchBox, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor.docSearch.searchBox, Qt.Key_Return, delay=KEY_DELAY)
assert abs(nwGUI.docEditor.getCursorPosition() - 1284) < 3
# Find next by button
- qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=keyDelay)
+ qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
assert abs(nwGUI.docEditor.getCursorPosition() - 1498) < 3
# Activate loop search
@@ -1323,14 +1265,14 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, nwLipsum):
assert nwGUI.docEditor.setCursorPosition(15)
# Toggle search again with header button
- qtbot.mouseClick(nwGUI.docEditor.docHeader.searchButton, Qt.LeftButton, delay=keyDelay)
+ qtbot.mouseClick(nwGUI.docEditor.docHeader.searchButton, Qt.LeftButton, delay=KEY_DELAY)
assert nwGUI.docEditor.docSearch.setSearchText("")
assert nwGUI.docEditor.docSearch.isVisible() is True
# Search for non-existing
nwGUI.docEditor.setCursorPosition(0)
assert nwGUI.docEditor.docSearch.setSearchText("abcdef")
- qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=keyDelay)
+ qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
assert nwGUI.docEditor.getCursorPosition() < 3 # No result
# Enable RegEx search
@@ -1341,19 +1283,19 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, nwLipsum):
# Set invalid RegEx
nwGUI.docEditor.setCursorPosition(0)
assert nwGUI.docEditor.docSearch.setSearchText(r"\bSus[")
- qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=keyDelay)
+ qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
assert nwGUI.docEditor.getCursorPosition() < 3 # No result
# Set dangerous RegEx (issue #1015)
# If this doesn't get caught, the app will hang
nwGUI.docEditor.setCursorPosition(0)
assert nwGUI.docEditor.docSearch.setSearchText(r".*")
- qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=keyDelay)
+ qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
assert abs(nwGUI.docEditor.getCursorPosition() - 14) < 3
# Set valid RegEx
assert nwGUI.docEditor.docSearch.setSearchText(r"\bSus")
- qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=keyDelay)
+ qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
assert abs(nwGUI.docEditor.getCursorPosition() - 208) < 3
# Find next and then prev
@@ -1404,7 +1346,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, nwLipsum):
assert abs(nwGUI.docEditor.getCursorPosition() - 208) < 3
# Replace "sus" with "foo" via replace button
- qtbot.mouseClick(nwGUI.docEditor.docSearch.replaceButton, Qt.LeftButton, delay=keyDelay)
+ qtbot.mouseClick(nwGUI.docEditor.docSearch.replaceButton, Qt.LeftButton, delay=KEY_DELAY)
assert nwGUI.docEditor.getText()[205:213] == "foocipit"
# Revert last two replaces
@@ -1482,7 +1424,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, nwLipsum):
monkeypatch.setattr(nwGUI.docEditor.docSearch.replaceBox, "hasFocus", lambda: True)
assert nwGUI.docEditor.focusNextPrevChild(True) is True
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiEditor_Search
diff --git a/tests/test_gui/test_gui_docviewer.py b/tests/test_gui/test_gui_docviewer.py
index ef76d51c..22057e15 100644
--- a/tests/test_gui/test_gui_docviewer.py
+++ b/tests/test_gui/test_gui_docviewer.py
@@ -23,25 +23,17 @@ import pytest
from PyQt5.QtCore import Qt, QUrl
from PyQt5.QtGui import QTextCursor
-from PyQt5.QtWidgets import qApp, QAction, QMessageBox
+from PyQt5.QtWidgets import qApp, QAction
from mock import causeException
from novelwriter.enum import nwDocAction
from novelwriter.core.tohtml import ToHtml
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
-
@pytest.mark.gui
def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, nwLipsum):
"""Test the document viewer.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
-
# Open project
assert nwGUI.openProject(nwLipsum)
@@ -184,6 +176,6 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, nwLipsum):
assert nwGUI.docViewer.loadText("846352075de7d") is False
assert nwGUI.docViewer.toPlainText() == "An error occurred while generating the preview."
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiViewer_Main
diff --git a/tests/test_gui/test_gui_guimain.py b/tests/test_gui/test_gui_guimain.py
index 5d434601..79fcbe52 100644
--- a/tests/test_gui/test_gui_guimain.py
+++ b/tests/test_gui/test_gui_guimain.py
@@ -37,17 +37,13 @@ from novelwriter.gui.projtree import GuiProjectTree
from novelwriter.gui.doceditor import GuiDocEditor
from novelwriter.gui.noveltree import GuiNovelView
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
+KEY_DELAY = 1
@pytest.mark.gui
-def testGuiMain_ProjectBlocker(monkeypatch, nwGUI):
+def testGuiMain_ProjectBlocker(nwGUI):
"""Test the blocking of features when there's no project open.
"""
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
-
# Test no-project blocking
assert nwGUI.closeProject() is True
assert nwGUI.saveProject() is False
@@ -74,9 +70,6 @@ def testGuiMain_ProjectBlocker(monkeypatch, nwGUI):
def testGuiMain_NewProject(monkeypatch, nwGUI, fncProj):
"""Test creating a new project.
"""
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# No data
with monkeypatch.context() as mp:
mp.setattr(GuiProjectWizard, "exec_", lambda *a: None)
@@ -113,8 +106,6 @@ def testGuiMain_NewProject(monkeypatch, nwGUI, fncProj):
def testGuiMain_ProjectTreeItems(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
"""Test handling of project tree items based on GUI focus states.
"""
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
-
buildTestProject(nwGUI, fncProj)
sHandle = "000000000000f"
@@ -165,9 +156,6 @@ def testGuiMain_ProjectTreeItems(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mockRnd):
"""Test the document editor.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *a: True)
monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True)
monkeypatch.setattr(QInputDialog, "getText", lambda *a, text: (text, True))
@@ -195,11 +183,9 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
compFile = os.path.join(refDir, "guiEditor_Main_Initial_nwProject.nwx")
copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
- qtbot.wait(stepDelay)
# Re-open project
assert nwGUI.openProject(fncProj)
- qtbot.wait(stepDelay)
# Check that we loaded the data
assert len(nwGUI.theProject.tree) == 8
@@ -241,18 +227,18 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
# Type something into the document
nwGUI.switchFocus(nwWidget.EDITOR)
- qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
for c in "# Jane Doe":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "@tag: Jane":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "This is a file about Jane.":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
# Add a Plot File
nwGUI.switchFocus(nwWidget.TREE)
@@ -263,18 +249,18 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
# Type something into the document
nwGUI.switchFocus(nwWidget.EDITOR)
- qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
for c in "# Main Plot":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "@tag: MainPlot":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "This is a file detailing the main plot.":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
# Add a World File
nwGUI.switchFocus(nwWidget.TREE)
@@ -290,18 +276,18 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
# Type something into the document
nwGUI.switchFocus(nwWidget.EDITOR)
- qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
for c in "# Main Location":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "@tag: Home":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "This is a file describing Jane's home.":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
# Trigger autosaves before making more changes
nwGUI._autoSaveDocument()
@@ -317,67 +303,67 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
# Type something into the document
nwGUI.switchFocus(nwWidget.EDITOR)
- qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
for c in "# Novel":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "## Chapter":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "@pov: Jane":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "@plot: MainPlot":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "### Scene":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "% How about a comment?":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "@pov: Jane":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "@plot: MainPlot":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "@location: Home":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "#### Some Section":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "@char: Jane":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "This is a paragraph of nonsense text.":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
# Don't allow Shift+Enter to insert a line separator (issue #1150)
for c in "This is another paragraph":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Enter, modifier=Qt.ShiftModifier, delay=typeDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Enter, modifier=Qt.ShiftModifier, delay=KEY_DELAY)
for c in "with a line separator in it.":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
# Auto-Replace
# ============
@@ -386,43 +372,43 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
"This is another paragraph of much longer nonsense text. "
"It is in fact 1 very very NONSENSICAL nonsense text! "
):
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
for c in "We can also try replacing \"quotes\", even single 'quotes' are replaced. ":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
for c in "Isn't that nice? ":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
for c in "We can hyphen-ate, make dashes -- and even longer dashes --- if we want. ":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
for c in "Ellipsis? Not a problem either ... ":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
for c in "How about three hyphens - -":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Left, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Backspace, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Right, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Left, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Backspace, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Right, delay=KEY_DELAY)
for c in "- for long dash? It works too.":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "\"Full line double quoted text.\"":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "'Full line single quoted text.'":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
# Insert spaces before and after quotes
nwGUI.mainConf.fmtPadBefore = "\u201d"
nwGUI.mainConf.fmtPadAfter = "\u201c"
for c in "Some \"double quoted text with spaces padded\".":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
nwGUI.mainConf.fmtPadBefore = ""
nwGUI.mainConf.fmtPadAfter = ""
@@ -431,24 +417,24 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
nwGUI.mainConf.fmtPadBefore = ":"
for c in "@object: NoSpaceAdded":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "% synopsis: No space before this colon.":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "Add space before this colon: See?":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "But don't add a double space : See?":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
nwGUI.mainConf.fmtPadBefore = ""
@@ -456,55 +442,49 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
# ================
for c in "\t\"Tab-indented text\"":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in ">\"Paragraph-indented text\"":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in ">>\"Right-aligned text\"":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in "\t'Tab-indented text'":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in ">'Paragraph-indented text'":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
for c in ">>'Right-aligned text'":
- qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
- qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
- qtbot.wait(stepDelay)
nwGUI.docEditor.wCounterDoc.run()
- qtbot.wait(stepDelay)
# Save the document
assert nwGUI.docEditor.docChanged()
assert nwGUI.saveDocument()
assert not nwGUI.docEditor.docChanged()
- qtbot.wait(stepDelay)
nwGUI.rebuildIndex()
- qtbot.wait(stepDelay)
# Open and view the edited document
nwGUI.switchFocus(nwWidget.VIEWER)
assert nwGUI.openDocument(C.hSceneDoc)
assert nwGUI.viewDocument(C.hSceneDoc)
- qtbot.wait(stepDelay)
assert nwGUI.saveProject()
assert nwGUI.closeDocViewer()
- qtbot.wait(stepDelay)
# Check a Quick Create and Delete
assert nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None)
@@ -553,11 +533,9 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
@pytest.mark.gui
-def testGuiMain_FocusFullMode(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
+def testGuiMain_FocusFullMode(qtbot, nwGUI, fncProj, mockRnd):
"""Test toggling focus mode in main window.
"""
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
-
buildTestProject(nwGUI, fncProj)
assert nwGUI.isFocusMode is False
@@ -596,6 +574,6 @@ def testGuiMain_FocusFullMode(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
nwGUI.toggleFullScreenMode()
assert nwGUI.mainConf.isFullScreen is False
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiMain_FocusFullMode
diff --git a/tests/test_gui/test_gui_mainmenu.py b/tests/test_gui/test_gui_mainmenu.py
index c4bf2dd3..e55e1039 100644
--- a/tests/test_gui/test_gui_mainmenu.py
+++ b/tests/test_gui/test_gui_mainmenu.py
@@ -32,24 +32,17 @@ from novelwriter.enum import nwDocAction, nwDocInsert
from novelwriter.constants import nwKeyWords, nwUnicode
from novelwriter.gui.doceditor import GuiDocEditor
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
-
@pytest.mark.gui
def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum):
"""Test the main menu Edit and Format entries.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True)
# Test Document Action with No Project
assert nwGUI.docEditor.docAction(nwDocAction.COPY) is False
assert nwGUI.openProject(nwLipsum) is True
- qtbot.wait(stepDelay)
# Split By Chapter
assert nwGUI.openDocument("4c4f28287af27") is True
@@ -61,57 +54,43 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum):
nwGUI.mainMenu.aFmtStrong.activate(QAction.Trigger)
fmtStr = "**Pellentesque** nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:90] == fmtStr
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aFmtStrong.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[39:86] == cleanText
- qtbot.wait(stepDelay)
# Italic
nwGUI.mainMenu.aFmtEmph.activate(QAction.Trigger)
fmtStr = "_Pellentesque_ nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:88] == fmtStr
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aFmtEmph.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[39:86] == cleanText
- qtbot.wait(stepDelay)
# Strikethrough
nwGUI.mainMenu.aFmtStrike.activate(QAction.Trigger)
fmtStr = "~~Pellentesque~~ nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:90] == fmtStr
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aFmtStrike.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[39:86] == cleanText
- qtbot.wait(stepDelay)
# Should get us back to plain
nwGUI.mainMenu.aFmtStrong.activate(QAction.Trigger)
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aFmtEmph.activate(QAction.Trigger)
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aFmtEmph.activate(QAction.Trigger)
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aFmtStrong.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[39:86] == cleanText
- qtbot.wait(stepDelay)
# Double Quotes
nwGUI.mainMenu.aFmtDQuote.activate(QAction.Trigger)
fmtStr = "“Pellentesque” nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:88] == fmtStr
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[39:86] == cleanText
- qtbot.wait(stepDelay)
# Single Quotes
nwGUI.mainMenu.aFmtSQuote.activate(QAction.Trigger)
fmtStr = "‘Pellentesque’ nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:88] == fmtStr
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[39:86] == cleanText
- qtbot.wait(stepDelay)
# Block Formats
# =============
@@ -121,61 +100,50 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum):
nwGUI.mainMenu.aFmtHead1.activate(QAction.Trigger)
fmtStr = "# Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:88] == fmtStr
- qtbot.wait(stepDelay)
# Header 2
nwGUI.mainMenu.aFmtHead2.activate(QAction.Trigger)
fmtStr = "## Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:89] == fmtStr
- qtbot.wait(stepDelay)
# Header 3
nwGUI.mainMenu.aFmtHead3.activate(QAction.Trigger)
fmtStr = "### Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:90] == fmtStr
- qtbot.wait(stepDelay)
# Header 4
nwGUI.mainMenu.aFmtHead4.activate(QAction.Trigger)
fmtStr = "#### Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:91] == fmtStr
- qtbot.wait(stepDelay)
# Clear Format
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[39:86] == cleanText
- qtbot.wait(stepDelay)
# Comment On
nwGUI.mainMenu.aFmtComment.activate(QAction.Trigger)
fmtStr = "% Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:88] == fmtStr
- qtbot.wait(stepDelay)
# Comment Off
nwGUI.mainMenu.aFmtComment.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[39:86] == cleanText
- qtbot.wait(stepDelay)
# Check comment with no space before text
assert nwGUI.docEditor.setCursorPosition(39)
assert nwGUI.docEditor.insertText("%")
fmtStr = "%Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:87] == fmtStr
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[39:86] == cleanText
- qtbot.wait(stepDelay)
# Undo/Redo
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger)
fmtStr = "%Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[39:87] == fmtStr
- qtbot.wait(stepDelay)
nwGUI.mainMenu.aEditRedo.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[39:86] == cleanText
- qtbot.wait(stepDelay)
# Cut, Copy and Paste
assert nwGUI.docEditor.setCursorPosition(39)
@@ -240,36 +208,30 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum):
nwGUI.mainMenu.aFmtAlignLeft.activate(QAction.Trigger)
fmtStr = "A single, short paragraph. <<"
assert nwGUI.docEditor.getText()[:29] == fmtStr
- qtbot.wait(stepDelay)
# Right Align
nwGUI.mainMenu.aFmtAlignRight.activate(QAction.Trigger)
fmtStr = ">> A single, short paragraph."
assert nwGUI.docEditor.getText()[:29] == fmtStr
- qtbot.wait(stepDelay)
# Centre Align
nwGUI.mainMenu.aFmtAlignCentre.activate(QAction.Trigger)
fmtStr = ">> A single, short paragraph. <<"
assert nwGUI.docEditor.getText()[:32] == fmtStr
- qtbot.wait(stepDelay)
# Left Indent
nwGUI.mainMenu.aFmtIndentLeft.activate(QAction.Trigger)
fmtStr = "> A single, short paragraph."
assert nwGUI.docEditor.getText()[:28] == fmtStr
- qtbot.wait(stepDelay)
# Right Indent
nwGUI.mainMenu.aFmtIndentRight.activate(QAction.Trigger)
fmtStr = "> A single, short paragraph. <"
assert nwGUI.docEditor.getText()[:30] == fmtStr
- qtbot.wait(stepDelay)
# No Format
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[:30] == cleanText
- qtbot.wait(stepDelay)
# Other Checks
@@ -368,21 +330,17 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum):
"Also text with \"double\" quotes which are \"less tricky\".\n\n"
)
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiMenu_EditFormat
@pytest.mark.gui
-def testGuiMenu_ContextMenus(qtbot, monkeypatch, nwGUI, nwLipsum):
+def testGuiMenu_ContextMenus(qtbot, nwGUI, nwLipsum):
"""Test the context menus.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
-
assert nwGUI.openProject(nwLipsum)
assert nwGUI.openDocument("4c4f28287af27")
- qtbot.wait(stepDelay)
# Editor Context Menu
theCursor = nwGUI.docEditor.textCursor()
@@ -452,7 +410,7 @@ def testGuiMenu_ContextMenus(qtbot, monkeypatch, nwGUI, nwLipsum):
assert nwGUI.docViewer.docHeader.backButton.isEnabled()
assert not nwGUI.docViewer.docHeader.forwardButton.isEnabled()
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiMenu_ContextMenus
@@ -461,10 +419,6 @@ def testGuiMenu_ContextMenus(qtbot, monkeypatch, nwGUI, nwLipsum):
def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd):
"""Test the Insert menu.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
buildTestProject(nwGUI, fncProj)
assert nwGUI.projView.projTree._getTreeItem(C.hSceneDoc) is not None
@@ -482,7 +436,7 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd):
assert nwGUI.docEditor.insertText(None) is False
assert nwGUI.docEditor.isEmpty()
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# Check Menu Entries
nwGUI.mainMenu.aInsENDash.activate(QAction.Trigger)
@@ -676,12 +630,12 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd):
assert nwGUI.docEditor.getText() == "Bar"
# The document isn't empty, so the message box should pop
- monkeypatch.setattr(QMessageBox, "question", lambda *a, **k: QMessageBox.No)
- assert not nwGUI.importDocument()
- assert nwGUI.docEditor.getText() == "Bar"
+ with monkeypatch.context() as mp:
+ mp.setattr(QMessageBox, "question", lambda *a, **k: QMessageBox.No)
+ assert not nwGUI.importDocument()
+ assert nwGUI.docEditor.getText() == "Bar"
# Finally, accept the replaced text, this time we use the menu entry to trigger it
- monkeypatch.setattr(QMessageBox, "question", lambda *a, **k: QMessageBox.Yes)
nwGUI.mainMenu.aImportFile.activate(QAction.Trigger)
assert nwGUI.docEditor.getText() == "Foo"
@@ -705,6 +659,6 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd):
assert theBits[0] == "The currently open file is saved in:"
assert theBits[1] == os.path.join(fncProj, "content", "000000000000f.nwd")
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testGuiMenu_Insert
diff --git a/tests/test_gui/test_gui_noveltree.py b/tests/test_gui/test_gui_noveltree.py
index e38d5555..4ec79000 100644
--- a/tests/test_gui/test_gui_noveltree.py
+++ b/tests/test_gui/test_gui_noveltree.py
@@ -26,7 +26,7 @@ from tools import C, buildTestProject, writeFile
from PyQt5.QtGui import QFocusEvent
from PyQt5.QtCore import Qt, QEvent
-from PyQt5.QtWidgets import QMessageBox, QToolTip
+from PyQt5.QtWidgets import QToolTip
from novelwriter.enum import nwWidget, nwItemType
from novelwriter.gui.noveltree import NovelTreeColumn
@@ -37,9 +37,6 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
"""Test navigating the novel tree.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
buildTestProject(nwGUI, fncProj)
diff --git a/tests/test_gui/test_gui_outline.py b/tests/test_gui/test_gui_outline.py
index 457be313..91467683 100644
--- a/tests/test_gui/test_gui_outline.py
+++ b/tests/test_gui/test_gui_outline.py
@@ -26,7 +26,7 @@ import pytest
from tools import buildTestProject, writeFile
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QWidget, QMessageBox, QAction
+from PyQt5.QtWidgets import QWidget, QAction
from novelwriter.enum import nwItemClass, nwOutline, nwView
@@ -35,10 +35,6 @@ from novelwriter.enum import nwItemClass, nwOutline, nwView
def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, fncDir):
"""Test the outline view.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
-
# Create a project
prjDir = os.path.join(fncDir, "project")
buildTestProject(nwGUI, prjDir)
@@ -156,13 +152,9 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, fncDir):
@pytest.mark.gui
-def testGuiOutline_Content(qtbot, monkeypatch, nwGUI, nwLipsum):
+def testGuiOutline_Content(qtbot, nwGUI, nwLipsum):
"""Test the outline view.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
-
assert nwGUI.openProject(nwLipsum)
nwGUI.mainConf.lastPath = nwLipsum
diff --git a/tests/test_gui/test_gui_projtree.py b/tests/test_gui/test_gui_projtree.py
index ecf78341..02efbb9a 100644
--- a/tests/test_gui/test_gui_projtree.py
+++ b/tests/test_gui/test_gui_projtree.py
@@ -40,11 +40,6 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
def testGuiProjTree_NewItems(qtbot, caplog, monkeypatch, nwGUI, fncDir, mockRnd):
"""Test adding and removing items from the project tree.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
projView = nwGUI.projView
@@ -177,11 +172,6 @@ def testGuiProjTree_NewItems(qtbot, caplog, monkeypatch, nwGUI, fncDir, mockRnd)
def testGuiProjTree_MoveItems(qtbot, monkeypatch, nwGUI, fncDir, mockRnd):
"""Test adding and removing items from the project tree.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
projView = nwGUI.projView
@@ -283,7 +273,7 @@ def testGuiProjTree_MoveItems(qtbot, monkeypatch, nwGUI, fncDir, mockRnd):
assert nwGUI.theProject.tree._treeOrder.index(C.hNovelRoot) == 0
# Clean up
- # qtbot.stopForInteraction()
+ # qtbot.stop()
nwGUI.closeProject()
# END Test testGuiProjTree_MoveItems
@@ -293,11 +283,6 @@ def testGuiProjTree_MoveItems(qtbot, monkeypatch, nwGUI, fncDir, mockRnd):
def testGuiProjTree_RequestDeleteItem(qtbot, caplog, monkeypatch, nwGUI, fncDir, mockRnd):
"""Test external requests for removing items from project tree.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
projView = nwGUI.projView
@@ -382,11 +367,6 @@ def testGuiProjTree_RequestDeleteItem(qtbot, caplog, monkeypatch, nwGUI, fncDir,
def testGuiProjTree_MoveItemToTrash(qtbot, caplog, monkeypatch, nwGUI, fncDir, mockRnd):
"""Test moving items to Trash.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
theProject = nwGUI.theProject
@@ -441,11 +421,6 @@ def testGuiProjTree_MoveItemToTrash(qtbot, caplog, monkeypatch, nwGUI, fncDir, m
def testGuiProjTree_PermanentlyDeleteItem(qtbot, caplog, monkeypatch, nwGUI, fncDir, mockRnd):
"""Test permanently deleting items.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
theProject = nwGUI.theProject
@@ -499,11 +474,6 @@ def testGuiProjTree_PermanentlyDeleteItem(qtbot, caplog, monkeypatch, nwGUI, fnc
def testGuiProjTree_EmptyTrash(qtbot, caplog, monkeypatch, nwGUI, fncDir, mockRnd):
"""Test emptying Trash.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
theProject = nwGUI.theProject
@@ -559,11 +529,6 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, fncDir, mockRnd):
"""Test the building of the project tree context menu. All this does
is test that the menu builds. It doesn't open the actual menu,
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
monkeypatch.setattr(QMenu, "exec_", lambda *a: None)
@@ -684,12 +649,6 @@ def testGuiProjTree_MergeDocuments(qtbot, monkeypatch, nwGUI, fncDir, mockRnd, i
"""
mergeData = {}
- # Block message box
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
-
monkeypatch.setattr(GuiDocMerge, "__init__", lambda *a: None)
monkeypatch.setattr(GuiDocMerge, "exec_", lambda *a: None)
monkeypatch.setattr(GuiDocMerge, "result", lambda *a: QDialog.Accepted)
@@ -794,12 +753,6 @@ def testGuiProjTree_SplitDocument(qtbot, monkeypatch, nwGUI, fncDir, mockRnd, ip
splitData = {}
splitText = []
- # Block message box
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
-
monkeypatch.setattr(GuiDocSplit, "__init__", lambda *a: None)
monkeypatch.setattr(GuiDocSplit, "exec_", lambda *a: None)
monkeypatch.setattr(GuiDocSplit, "result", lambda *a: QDialog.Accepted)
@@ -907,12 +860,6 @@ def testGuiProjTree_Other(qtbot, monkeypatch, nwGUI, fncDir, mockRnd):
"""Test various parts of the project tree class not covered by
other tests.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
-
# Create a project
prjDir = os.path.join(fncDir, "project")
buildTestProject(nwGUI, prjDir)
diff --git a/tests/test_gui/test_gui_statusbar.py b/tests/test_gui/test_gui_statusbar.py
index e2e9a5bb..30d8d861 100644
--- a/tests/test_gui/test_gui_statusbar.py
+++ b/tests/test_gui/test_gui_statusbar.py
@@ -24,18 +24,14 @@ import pytest
from tools import C, buildTestProject
-from PyQt5.QtWidgets import QMessageBox
-
from novelwriter.enum import nwState
from novelwriter.core.document import NWDoc
@pytest.mark.gui
-def testGuiStatusBar_Main(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
+def testGuiStatusBar_Main(qtbot, nwGUI, fncProj, mockRnd):
"""Test the the various features of the status bar.
"""
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
-
buildTestProject(nwGUI, fncProj)
cHandle = nwGUI.theProject.newFile("A Note", C.hCharRoot)
newDoc = NWDoc(nwGUI.theProject, cHandle)
diff --git a/tests/test_gui/test_gui_theme.py b/tests/test_gui/test_gui_theme.py
index 6cd82e64..3c6503cb 100644
--- a/tests/test_gui/test_gui_theme.py
+++ b/tests/test_gui/test_gui_theme.py
@@ -29,20 +29,16 @@ from mock import causeOSError
from tools import writeFile
from PyQt5.QtGui import QPalette
-from PyQt5.QtWidgets import QApplication, QMessageBox
+from PyQt5.QtWidgets import QApplication
from novelwriter.config import Config
from novelwriter.gui.theme import GuiTheme
@pytest.mark.gui
-def testGuiTheme_Main(qtbot, monkeypatch, nwGUI, fncDir):
+def testGuiTheme_Main(qtbot, nwGUI, fncDir):
"""Test the theme class init.
"""
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
-
mainTheme: GuiTheme = nwGUI.mainTheme
mainConf: Config = nwGUI.mainConf
@@ -128,10 +124,6 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwGUI, fncDir):
def testGuiTheme_Themes(qtbot, monkeypatch, nwGUI, fncDir):
"""Test the theme class init.
"""
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
-
mainTheme: GuiTheme = nwGUI.mainTheme
mainConf: Config = nwGUI.mainConf
diff --git a/tests/test_tools/test_tools_build.py b/tests/test_tools/test_tools_build.py
index 40e30dea..e0088a1c 100644
--- a/tests/test_tools/test_tools_build.py
+++ b/tests/test_tools/test_tools_build.py
@@ -26,22 +26,16 @@ from shutil import copyfile
from tools import cmpFiles, getGuiItem
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QAction, QMessageBox, QFileDialog
+from PyQt5.QtWidgets import QAction, QFileDialog
from novelwriter.tools import GuiBuildNovel
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
-
@pytest.mark.gui
def testToolBuild_Main(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir):
"""Test the build tool.
"""
# Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda a, b, c, **k: (c, None))
# Check that we cannot open when there is no project
@@ -121,27 +115,17 @@ def testToolBuild_Main(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir):
# Change Title Formats and Flip Switches
nwBuild.fmtChapter.setText(r"Chapter %chw%: %title%")
- qtbot.wait(stepDelay)
nwBuild.fmtScene.setText(r"Scene %ch%.%sc%: %title%")
- qtbot.wait(stepDelay)
nwBuild.fmtSection.setText(r"%ch%.%sc%.1: %title%")
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.justifyText, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.includeSynopsis, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.includeComments, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.includeKeywords, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.replaceUCode, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.noteFiles, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.ignoreFlag, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)
@@ -175,7 +159,6 @@ def testToolBuild_Main(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir):
# Replace Tabs with Spaces
qtbot.mouseClick(nwBuild.replaceTabs, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)
@@ -210,20 +193,13 @@ def testToolBuild_Main(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir):
# Putline Mode
nwBuild.fmtChapter.setText(r"Chapter %chw%: %title%")
- qtbot.wait(stepDelay)
nwBuild.fmtScene.setText(r"Scene %sca%: %title%")
- qtbot.wait(stepDelay)
nwBuild.fmtSection.setText(r"Section: %title%")
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.includeComments, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.noteFiles, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.ignoreFlag, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.includeBody, Qt.LeftButton)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)
@@ -287,6 +263,6 @@ def testToolBuild_Main(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir):
nwBuild._doClose()
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testToolBuild_Main
diff --git a/tests/test_tools/test_tools_lipsum.py b/tests/test_tools/test_tools_lipsum.py
index de70a428..0bd07f97 100644
--- a/tests/test_tools/test_tools_lipsum.py
+++ b/tests/test_tools/test_tools_lipsum.py
@@ -23,18 +23,15 @@ import pytest
from tools import C, getGuiItem, buildTestProject
-from PyQt5.QtWidgets import QAction, QMessageBox
+from PyQt5.QtWidgets import QAction
from novelwriter.tools import GuiLipsum
@pytest.mark.gui
-def testToolLipsum_Main(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
+def testToolLipsum_Main(qtbot, nwGUI, fncProj, mockRnd):
"""Test the Lorem Ipsum tool.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
-
# Check that we cannot open when there is no project
nwGUI.mainMenu.aLipsumText.activate(QAction.Trigger)
assert getGuiItem("GuiLipsum") is None
@@ -70,6 +67,6 @@ def testToolLipsum_Main(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
# Close
nwLipsum._doClose()
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testToolLipsum_Main
diff --git a/tests/test_tools/test_tools_projwizard.py b/tests/test_tools/test_tools_projwizard.py
index afe720ff..a2facf6e 100644
--- a/tests/test_tools/test_tools_projwizard.py
+++ b/tests/test_tools/test_tools_projwizard.py
@@ -26,7 +26,7 @@ import pytest
from tools import getGuiItem
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QFileDialog, QWizard, QMessageBox, QDialog
+from PyQt5.QtWidgets import QFileDialog, QWizard, QDialog
from novelwriter.enum import nwItemClass
from novelwriter.tools.projwizard import (
@@ -34,10 +34,6 @@ from novelwriter.tools.projwizard import (
ProjWizardPopulatePage, ProjWizardCustomPage, ProjWizardFinalPage
)
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
-
@pytest.mark.gui
@pytest.mark.skipif(sys.platform.startswith("darwin"), reason="Not running on Darwin")
@@ -45,13 +41,8 @@ def testToolProjectWizard_Handling(qtbot, monkeypatch, nwGUI, nwMinimal):
"""Test the launch of the project wizard.
Disabled for macOS because the test segfaults on QWizard.show()
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
- ##
- # Test New Project Function
- ##
+ # Test New Project Function
+ # ========================
# New with a project open should cause an error
assert nwGUI.openProject(nwMinimal)
@@ -73,9 +64,8 @@ def testToolProjectWizard_Handling(qtbot, monkeypatch, nwGUI, nwMinimal):
mp.setattr(nwGUI, "showNewProjectDialog", lambda *a: {"projPath": nwMinimal})
assert nwGUI.newProject() is False
- ##
- # Test the Wizard Launching
- ##
+ # Test the Wizard Launching
+ # =========================
nwGUI.mainConf.lastPath = " "
monkeypatch.setattr(GuiProjectWizard, "exec_", lambda *a: None)
@@ -87,7 +77,6 @@ def testToolProjectWizard_Handling(qtbot, monkeypatch, nwGUI, nwMinimal):
assert isinstance(nwWiz, GuiProjectWizard)
nwWiz.show()
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwWiz.button(QWizard.CancelButton), Qt.LeftButton)
assert result is None
@@ -100,7 +89,7 @@ def testToolProjectWizard_Handling(qtbot, monkeypatch, nwGUI, nwMinimal):
nwWiz.reject()
nwWiz.close()
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testToolProjectWizard_Handling
@@ -111,14 +100,12 @@ def testToolProjectWizard_Handling(qtbot, monkeypatch, nwGUI, nwMinimal):
def testToolProjectWizard_Run(qtbot, monkeypatch, nwGUI, fncDir, prjType):
"""Test the new project wizard with a set of selection scenarios.
"""
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiProjectWizard, "exec_", lambda *a: None)
nwGUI.mainConf.lastPath = " "
nwWiz = GuiProjectWizard(nwGUI)
nwWiz.show()
- qtbot.wait(stepDelay)
+ qtbot.addWidget(nwWiz)
# Intro Page
# ==========
@@ -134,7 +121,6 @@ def testToolProjectWizard_Run(qtbot, monkeypatch, nwGUI, fncDir, prjType):
# Setting projName should activate the button
assert nwWiz.button(QWizard.NextButton).isEnabled()
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwWiz.button(QWizard.NextButton), Qt.LeftButton)
# Folder Page
@@ -173,7 +159,6 @@ def testToolProjectWizard_Run(qtbot, monkeypatch, nwGUI, fncDir, prjType):
# Setting projPath should activate the button
assert nwWiz.button(QWizard.NextButton).isEnabled()
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwWiz.button(QWizard.NextButton), Qt.LeftButton)
# Populate Page
@@ -183,7 +168,6 @@ def testToolProjectWizard_Run(qtbot, monkeypatch, nwGUI, fncDir, prjType):
assert isinstance(popPage, ProjWizardPopulatePage)
assert nwWiz.button(QWizard.NextButton).isEnabled()
- qtbot.wait(stepDelay)
if prjType.startswith("minimal"):
popPage.popMinimal.setChecked(True)
elif prjType.startswith("custom"):
@@ -191,7 +175,6 @@ def testToolProjectWizard_Run(qtbot, monkeypatch, nwGUI, fncDir, prjType):
elif prjType.startswith("sample"):
popPage.popSample.setChecked(True)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwWiz.button(QWizard.NextButton), Qt.LeftButton)
# Custom Page
@@ -219,7 +202,6 @@ def testToolProjectWizard_Run(qtbot, monkeypatch, nwGUI, fncDir, prjType):
customPage.numChapters.setValue(0)
customPage.numScenes.setValue(10)
- qtbot.wait(stepDelay)
qtbot.mouseClick(nwWiz.button(QWizard.NextButton), Qt.LeftButton)
# Final Page
@@ -264,6 +246,6 @@ def testToolProjectWizard_Run(qtbot, monkeypatch, nwGUI, fncDir, prjType):
nwWiz.reject()
nwWiz.close()
- # qtbot.stopForInteraction()
+ # qtbot.stop()
# END Test testToolProjectWizard_Run
diff --git a/tests/test_tools/test_tools_writingstats.py b/tests/test_tools/test_tools_writingstats.py
index b7358b20..a4ba1963 100644
--- a/tests/test_tools/test_tools_writingstats.py
+++ b/tests/test_tools/test_tools_writingstats.py
@@ -27,26 +27,16 @@ from mock import causeOSError
from tools import getGuiItem, writeFile, buildTestProject
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QAction, QFileDialog, QMessageBox
+from PyQt5.QtWidgets import QAction, QFileDialog
from novelwriter.tools import GuiWritingStats
from novelwriter.constants import nwFiles
-keyDelay = 2
-typeDelay = 1
-stepDelay = 20
-
@pytest.mark.gui
def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
"""Test the full writing stats tool.
"""
- # Block message box
- monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
- monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
-
# Create a project to work on
buildTestProject(nwGUI, fncProj)
qtbot.wait(100)
@@ -60,7 +50,6 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
sessLog = getGuiItem("GuiWritingStats")
assert isinstance(sessLog, GuiWritingStats)
- qtbot.wait(stepDelay)
# Test Loading
# ============
@@ -186,9 +175,7 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
# No Novel Files
qtbot.mouseClick(sessLog.incNovel, Qt.LeftButton)
- qtbot.wait(stepDelay)
assert sessLog._saveData(sessLog.FMT_JSON)
- qtbot.wait(stepDelay)
jsonStats = os.path.join(fncDir, "sessionStats.json")
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
@@ -234,9 +221,7 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
# No Note Files
qtbot.mouseClick(sessLog.incNovel, Qt.LeftButton)
qtbot.mouseClick(sessLog.incNotes, Qt.LeftButton)
- qtbot.wait(stepDelay)
assert sessLog._saveData(sessLog.FMT_JSON)
- qtbot.wait(stepDelay)
jsonStats = os.path.join(fncDir, "sessionStats.json")
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
@@ -282,11 +267,9 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
# No Negative Entries
qtbot.mouseClick(sessLog.incNotes, Qt.LeftButton)
qtbot.mouseClick(sessLog.hideNegative, Qt.LeftButton)
- qtbot.wait(stepDelay)
assert sessLog._saveData(sessLog.FMT_JSON)
- qtbot.wait(stepDelay)
- # qtbot.stopForInteraction()
+ # qtbot.stop()
jsonStats = os.path.join(fncDir, "sessionStats.json")
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
@@ -316,9 +299,7 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
# Un-hide Zero Entries
qtbot.mouseClick(sessLog.hideNegative, Qt.LeftButton)
qtbot.mouseClick(sessLog.hideZeros, Qt.LeftButton)
- qtbot.wait(stepDelay)
assert sessLog._saveData(sessLog.FMT_JSON)
- qtbot.wait(stepDelay)
jsonStats = os.path.join(fncDir, "sessionStats.json")
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
@@ -371,9 +352,7 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
# Group by Day
qtbot.mouseClick(sessLog.groupByDay, Qt.LeftButton)
- qtbot.wait(stepDelay)
assert sessLog._saveData(sessLog.FMT_JSON)
- qtbot.wait(stepDelay)
jsonStats = os.path.join(fncDir, "sessionStats.json")
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
@@ -422,10 +401,9 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
assert not sessLog._loadLogFile()
assert not sessLog._saveData(sessLog.FMT_CSV)
- # qtbot.stopForInteraction()
+ # qtbot.stop()
sessLog._doClose()
assert nwGUI.closeProject()
- qtbot.wait(stepDelay)
# END Test testToolWritingStats_Main