Clean up a lot more namespace flags

This commit is contained in:
Veronica Berglyd Olsen
2024-04-03 20:25:54 +02:00
parent 46c5f1c10d
commit 20c5993e2d
38 changed files with 184 additions and 142 deletions
+3 -3
View File
@@ -47,7 +47,7 @@ def testDlgOther_QuoteSelect(qtbot, monkeypatch, nwGUI):
assert nwQuot.previewLabel.text() == lastItem
nwQuot.accept()
assert nwQuot.result() == QDialog.Accepted
assert nwQuot.result() == QDialog.DialogCode.Accepted
assert nwQuot.selectedQuote == lastItem
nwQuot.close()
@@ -71,13 +71,13 @@ def testDlgOther_EditLabel(qtbot, monkeypatch):
monkeypatch.setattr(GuiEditLabel, "exec", lambda *a: None)
with monkeypatch.context() as mp:
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.Accepted)
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.DialogCode.Accepted)
newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World") # type: ignore
assert dlgOk is True
assert newLabel == "Hello World"
with monkeypatch.context() as mp:
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.Rejected)
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.DialogCode.Rejected)
newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World") # type: ignore
assert dlgOk is False
assert newLabel == "Hello World"
+6 -6
View File
@@ -24,13 +24,13 @@ import pytest
from PyQt5.QtGui import QFontDatabase, QKeyEvent
from PyQt5.QtCore import QEvent, Qt
from PyQt5.QtWidgets import QAction, QDialogButtonBox, QFileDialog, QFontDialog
from PyQt5.QtWidgets import QAction, QFileDialog, QFontDialog
from novelwriter import CONFIG, SHARED
from novelwriter.constants import nwConst, nwUnicode
from novelwriter.dialogs.preferences import GuiPreferences
from novelwriter.dialogs.quotes import GuiQuoteSelect
from novelwriter.types import QtModeNone
from novelwriter.types import QtDialogApply, QtDialogClose, QtDialogSave, QtModeNone
KEY_DELAY = 1
@@ -122,21 +122,21 @@ def testDlgPreferences_Actions(qtbot, monkeypatch, nwGUI):
# Check Apply Button
prefs.show()
with qtbot.waitSignal(prefs.newPreferencesReady) as signal:
prefs.buttonBox.button(QDialogButtonBox.StandardButton.Apply).click()
prefs.buttonBox.button(QtDialogApply).click()
assert signal.args == [False, False, False, False]
# Check Save Button
prefs.show()
with qtbot.waitSignal(prefs.newPreferencesReady) as signal:
with qtbot.waitSignal(prefs.finished) as status:
prefs.buttonBox.button(QDialogButtonBox.StandardButton.Save).click()
prefs.buttonBox.button(QtDialogSave).click()
assert signal.args == [False, False, False, False]
assert status.args == [nwConst.DLG_FINISHED]
# Check Close Button
prefs.show()
with qtbot.waitSignal(prefs.finished) as status:
prefs.buttonBox.button(QDialogButtonBox.StandardButton.Close).click()
prefs.buttonBox.button(QtDialogClose).click()
assert status.args == [nwConst.DLG_FINISHED]
# Close Using Escape Key
@@ -333,7 +333,7 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, tstPaths):
with monkeypatch.context() as mp:
mp.setattr(QFontDatabase, "families", lambda *a: ["TestFont"])
with qtbot.waitSignal(prefs.newPreferencesReady) as signal:
prefs.buttonBox.button(QDialogButtonBox.StandardButton.Apply).click()
prefs.buttonBox.button(QtDialogApply).click()
assert signal.args == [True, True, True, True]
# Check Settings
@@ -44,7 +44,7 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI):
"""
# Block the GUI blocking thread
monkeypatch.setattr(GuiProjectSettings, "exec", lambda *a: None)
monkeypatch.setattr(GuiProjectSettings, "result", lambda *a: QDialog.Accepted)
monkeypatch.setattr(GuiProjectSettings, "result", lambda *a: QDialog.DialogCode.Accepted)
# Check that we cannot open when there is no project
nwGUI.mainMenu.aProjectSettings.activate(QAction.Trigger)
+1 -1
View File
@@ -39,7 +39,7 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, fncPath, projPath):
buildTestProject(nwGUI, projPath)
monkeypatch.setattr(GuiWordList, "exec", lambda *a: None)
monkeypatch.setattr(GuiWordList, "result", lambda *a: QDialog.Accepted)
monkeypatch.setattr(GuiWordList, "result", lambda *a: QDialog.DialogCode.Accepted)
monkeypatch.setattr(GuiWordList, "accept", lambda *a: None)
# Open project