Also added basic check of exceptinHandler

This commit is contained in:
Veronica K. B. Olsen
2020-09-19 17:38:25 +02:00
parent ffab0b35a8
commit 17173f65d3
2 changed files with 11 additions and 3 deletions
+5 -2
View File
@@ -135,7 +135,7 @@ class NWErrorMessage(QDialog):
# END Class NWErrorMessage
def exceptionHandler(exType, exValue, exTrace):
def exceptionHandler(exType, exValue, exTrace, testMode=False):
"""Function to catch unhandled global exceptions.
"""
import nw
@@ -173,7 +173,10 @@ def exceptionHandler(exType, exValue, exTrace):
logger.critical("Could not close the project before exiting")
logger.critical(str(e))
qApp.exit(1)
if testMode:
return errMsg.msgBody.toPlainText()
else:
qApp.exit(1)
except Exception as e:
logger.critical(str(e))
+6 -1
View File
@@ -8,7 +8,7 @@ import pytest
from PyQt5.QtWidgets import qApp
from nw.error import NWErrorMessage
from nw.error import NWErrorMessage, exceptionHandler
@pytest.mark.error
def testErrorDialog(qtbot, nwFuncTemp, nwTemp):
@@ -35,6 +35,11 @@ def testErrorDialog(qtbot, nwFuncTemp, nwTemp):
nwErr._doClose()
nwErr.close()
theMessage = exceptionHandler(Exception, "Second Error", sys.last_traceback, testMode=True)
assert theMessage
assert "Second Error" in theMessage
assert "Exception" in theMessage
nwGUI.closeMain()
# qtbot.stopForInteraction()