私は単体テストを実行していますが、例外がスローされていることがわかります。しかし、私はちょうど正確に何が投げられるのか分かりません。Python:投げられる例外を見ることができません
from pt_hil.utilities.PT_HIL_Interface_Utils.widgets import PathPicker
import unittest
import wx
class TestUM(unittest.TestCase):
@classmethod
def setUpClass(cls):
print 'setUpClass called'
cls.path_picker = PathPicker()
print 'path_picker has been declared'
def test_PathPicker(self):
self.assertRaises(NotImplementedError, wx.UIActionSimulator.MouseClick(self.path_picker.browse))
if __name__ == '__main__':
unittest.main()
PathPickerクラス:
class PathPicker(Widget):
def __init__(self, parent=None, name="PathPicker"):
print 'hi1'
try:
Widget.__init__(self, name, parent)
except Exception as e:
print 'hello'
return logging.error(traceback.format_exc())
print 'hi2'
私はユニットテストを実行したときに私が得る出力は次のようになります。
setUpClass called
hi1
Process finished with exit code 1
ので明確に、何かがで間違って起こっている:Widget.__init__(self, name, parent)
が、私はできますそれが何であるかは分かりません。どのような例外やエラーがスローされて印刷するためにこれを得ることができる方法はありますか?
編集:ここではそれと一緒に行くためのWidgetクラスです:
class Widget(QWidget):
def __init__(self, name, parent=None):
print 'hey2'
try:
super(Widget, self).__init__()
except BaseException as e:
print 'hello'
return logging.error(traceback.format_exc())
print 'hey3'
今、それは私を与えている:
setUpClass called
hi1
hey2
Process finished with exit code 1
私はそれを試みました。そして何も変わっていない。奇妙な。また、編集を確認します。 – BUInvent
ああ、QtWidget initで何か不思議なことが起きていて、プログラムの実行を止めることを決めている: '( –
@SlakNation回答は新しい情報で編集されました –