Remove some more test flags in the main code
This commit is contained in:
+19
-21
@@ -774,14 +774,13 @@ class GuiBuildNovel(QDialog):
|
|||||||
if not os.path.isdir(saveDir):
|
if not os.path.isdir(saveDir):
|
||||||
saveDir = self.mainConf.homePath
|
saveDir = self.mainConf.homePath
|
||||||
|
|
||||||
if self.mainConf.showGUI:
|
dlgOpt = QFileDialog.Options()
|
||||||
dlgOpt = QFileDialog.Options()
|
dlgOpt |= QFileDialog.DontUseNativeDialog
|
||||||
dlgOpt |= QFileDialog.DontUseNativeDialog
|
savePath, _ = QFileDialog.getSaveFileName(
|
||||||
savePath, _ = QFileDialog.getSaveFileName(
|
self, "Save Document As", savePath, options=dlgOpt
|
||||||
self, "Save Document As", savePath, options=dlgOpt
|
)
|
||||||
)
|
if not savePath:
|
||||||
if not savePath:
|
return False
|
||||||
return False
|
|
||||||
|
|
||||||
self.mainConf.setLastPath(savePath)
|
self.mainConf.setLastPath(savePath)
|
||||||
|
|
||||||
@@ -887,19 +886,18 @@ class GuiBuildNovel(QDialog):
|
|||||||
errMsg = "Unknown format"
|
errMsg = "Unknown format"
|
||||||
|
|
||||||
# Report to user
|
# Report to user
|
||||||
if self.mainConf.showGUI:
|
if wSuccess:
|
||||||
if wSuccess:
|
self.theParent.makeAlert(
|
||||||
self.theParent.makeAlert(
|
"%s file successfully written to:<br> %s" % (
|
||||||
"%s file successfully written to:<br> %s" % (
|
textFmt, savePath
|
||||||
textFmt, savePath
|
), nwAlert.INFO
|
||||||
), nwAlert.INFO
|
)
|
||||||
)
|
else:
|
||||||
else:
|
self.theParent.makeAlert(
|
||||||
self.theParent.makeAlert(
|
"Failed to write %s file. %s" % (
|
||||||
"Failed to write %s file. %s" % (
|
textFmt, errMsg
|
||||||
textFmt, errMsg
|
), nwAlert.ERROR
|
||||||
), nwAlert.ERROR
|
)
|
||||||
)
|
|
||||||
|
|
||||||
return wSuccess
|
return wSuccess
|
||||||
|
|
||||||
|
|||||||
+10
-11
@@ -971,17 +971,16 @@ class GuiMain(QMainWindow):
|
|||||||
logger.error(msgLine)
|
logger.error(msgLine)
|
||||||
|
|
||||||
# Popup
|
# Popup
|
||||||
if self.mainConf.showGUI:
|
msgBox = QMessageBox()
|
||||||
msgBox = QMessageBox()
|
if theLevel == nwAlert.INFO:
|
||||||
if theLevel == nwAlert.INFO:
|
msgBox.information(self, "Information", popMsg)
|
||||||
msgBox.information(self, "Information", popMsg)
|
elif theLevel == nwAlert.WARN:
|
||||||
elif theLevel == nwAlert.WARN:
|
msgBox.warning(self, "Warning", popMsg)
|
||||||
msgBox.warning(self, "Warning", popMsg)
|
elif theLevel == nwAlert.ERROR:
|
||||||
elif theLevel == nwAlert.ERROR:
|
msgBox.critical(self, "Error", popMsg)
|
||||||
msgBox.critical(self, "Error", popMsg)
|
elif theLevel == nwAlert.BUG:
|
||||||
elif theLevel == nwAlert.BUG:
|
popMsg += "<br>This is a bug!"
|
||||||
popMsg += "<br>This is a bug!"
|
msgBox.critical(self, "Internal Error", popMsg)
|
||||||
msgBox.critical(self, "Internal Error", popMsg)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ def testBaseInit_Options(monkeypatch, tmpDir):
|
|||||||
nwGUI = nw.main()
|
nwGUI = nw.main()
|
||||||
assert nw.logger.getEffectiveLevel() == logging.WARNING
|
assert nw.logger.getEffectiveLevel() == logging.WARNING
|
||||||
assert nw.CONFIG.debugInfo is False
|
assert nw.CONFIG.debugInfo is False
|
||||||
assert nw.CONFIG.showGUI is False
|
|
||||||
assert nwGUI.closeMain() == "closeMain"
|
assert nwGUI.closeMain() == "closeMain"
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from shutil import copyfile
|
|||||||
from tools import cmpFiles, getGuiItem
|
from tools import cmpFiles, getGuiItem
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import QAction, QMessageBox
|
from PyQt5.QtWidgets import QAction, QMessageBox, QFileDialog
|
||||||
|
|
||||||
from nw.gui import GuiBuildNovel
|
from nw.gui import GuiBuildNovel
|
||||||
|
|
||||||
@@ -23,6 +23,8 @@ def testGuiBuild_Tool(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir):
|
|||||||
"""
|
"""
|
||||||
# Block message box
|
# Block message box
|
||||||
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
|
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
|
||||||
|
monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes)
|
||||||
|
monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda a, b, c, **kwargs: (c, None))
|
||||||
|
|
||||||
# Check that we cannot open when there is no project
|
# Check that we cannot open when there is no project
|
||||||
nwGUI.mainMenu.aBuildProject.activate(QAction.Trigger)
|
nwGUI.mainMenu.aBuildProject.activate(QAction.Trigger)
|
||||||
|
|||||||
Reference in New Issue
Block a user