Also remove the gui blocking from the error handler
This commit is contained in:
+1
-3
@@ -138,7 +138,6 @@ class NWErrorMessage(QDialog):
|
|||||||
def exceptionHandler(exType, exValue, exTrace):
|
def exceptionHandler(exType, exValue, exTrace):
|
||||||
"""Function to catch unhandled global exceptions.
|
"""Function to catch unhandled global exceptions.
|
||||||
"""
|
"""
|
||||||
import nw
|
|
||||||
import logging
|
import logging
|
||||||
from traceback import print_tb
|
from traceback import print_tb
|
||||||
from PyQt5.QtWidgets import qApp
|
from PyQt5.QtWidgets import qApp
|
||||||
@@ -160,8 +159,7 @@ def exceptionHandler(exType, exValue, exTrace):
|
|||||||
|
|
||||||
errMsg = NWErrorMessage(nwGUI)
|
errMsg = NWErrorMessage(nwGUI)
|
||||||
errMsg.setMessage(exType, exValue, exTrace)
|
errMsg.setMessage(exType, exValue, exTrace)
|
||||||
if nw.CONFIG.showGUI:
|
errMsg.exec_()
|
||||||
errMsg.exec_()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Try a controlled shudown
|
# Try a controlled shudown
|
||||||
|
|||||||
+18
-22
@@ -66,33 +66,29 @@ def testBaseError_Handler(qtbot, monkeypatch, fncDir, tmpDir):
|
|||||||
qtbot.waitForWindowShown(nwGUI)
|
qtbot.waitForWindowShown(nwGUI)
|
||||||
|
|
||||||
# Normal shutdown
|
# Normal shutdown
|
||||||
monkeypatch.setattr("PyQt5.QtWidgets.qApp.exit", lambda x: None)
|
monkeypatch.setattr(NWErrorMessage, "exec_", lambda *args: None)
|
||||||
nwGUI.mainConf.showGUI = True
|
monkeypatch.setattr("PyQt5.QtWidgets.qApp.exit", lambda *args: None)
|
||||||
exceptionHandler(Exception, "Error Message", None)
|
|
||||||
nwGUI.mainConf.showGUI = False
|
|
||||||
monkeypatch.undo()
|
|
||||||
|
|
||||||
# Disable blocking of GUI
|
|
||||||
monkeypatch.setattr("PyQt5.QtWidgets.QDialog.exec_", lambda: None)
|
|
||||||
monkeypatch.setattr("PyQt5.QtWidgets.qApp.exit", lambda x: None)
|
|
||||||
exceptionHandler(Exception, "Error Message", None)
|
|
||||||
monkeypatch.undo()
|
|
||||||
|
|
||||||
# Should handle qApp failing
|
|
||||||
monkeypatch.setattr("PyQt5.QtWidgets.qApp.topLevelWidgets", causeException)
|
|
||||||
monkeypatch.setattr("PyQt5.QtWidgets.qApp.exit", lambda x: None)
|
|
||||||
exceptionHandler(Exception, "Error Message", None)
|
|
||||||
monkeypatch.undo()
|
|
||||||
|
|
||||||
# Should handle failing to close main GUI
|
|
||||||
monkeypatch.setattr(nwGUI, "closeMain", causeException)
|
|
||||||
monkeypatch.setattr("PyQt5.QtWidgets.qApp.exit", lambda x: None)
|
|
||||||
exceptionHandler(Exception, "Error Message", None)
|
exceptionHandler(Exception, "Error Message", None)
|
||||||
monkeypatch.undo()
|
monkeypatch.undo()
|
||||||
|
|
||||||
# Should not crash when no GUI is found
|
# Should not crash when no GUI is found
|
||||||
|
monkeypatch.setattr(NWErrorMessage, "exec_", lambda *args: None)
|
||||||
|
monkeypatch.setattr("PyQt5.QtWidgets.qApp.exit", lambda *args: None)
|
||||||
monkeypatch.setattr("PyQt5.QtWidgets.qApp.topLevelWidgets", lambda: [])
|
monkeypatch.setattr("PyQt5.QtWidgets.qApp.topLevelWidgets", lambda: [])
|
||||||
monkeypatch.setattr("PyQt5.QtWidgets.qApp.exit", lambda x: None)
|
exceptionHandler(Exception, "Error Message", None)
|
||||||
|
monkeypatch.undo()
|
||||||
|
|
||||||
|
# Should handle qApp failing
|
||||||
|
monkeypatch.setattr(NWErrorMessage, "exec_", lambda *args: None)
|
||||||
|
monkeypatch.setattr("PyQt5.QtWidgets.qApp.exit", lambda *args: None)
|
||||||
|
monkeypatch.setattr("PyQt5.QtWidgets.qApp.topLevelWidgets", causeException)
|
||||||
|
exceptionHandler(Exception, "Error Message", None)
|
||||||
|
monkeypatch.undo()
|
||||||
|
|
||||||
|
# Should handle failing to close main GUI
|
||||||
|
monkeypatch.setattr(NWErrorMessage, "exec_", lambda *args: None)
|
||||||
|
monkeypatch.setattr("PyQt5.QtWidgets.qApp.exit", lambda *args: None)
|
||||||
|
monkeypatch.setattr(nwGUI, "closeMain", causeException)
|
||||||
exceptionHandler(Exception, "Error Message", None)
|
exceptionHandler(Exception, "Error Message", None)
|
||||||
monkeypatch.undo()
|
monkeypatch.undo()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user