据我所见,如果在PyQt下的插槽中发生异常,则会将异常打印到屏幕,但不会冒泡.这会在我的测试策略中产生问题,因为如果插槽中发生异常,我将看不到测试失败.
这是一个例子:
import sys
from PyQt4 import QtGui, QtCore
class Test(QtGui.QPushButton):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setText("hello")
self.connect(self, QtCore.SIGNAL("clicked()"), self.buttonClicked)
def buttonClicked(self):
print "clicked"
raise Exception("wow")
app=QtGui.QApplication(sys.argv)
t=Test()
t.show()
try:
app.exec_()
except:
print "exiting"
Run Code Online (Sandbox Code Playgroud)
请注意异常永远不会退出程序.
有办法解决这个问题吗?