Hello
I am using custom event in a wxpython gui but I encounter problems with unit test.
Please find enclosed my example codes.
In
my example, when the users clicks on the button, MyWidget posts a custom event. This event is caught by the main frame and the label is set to ‘Event Ok’.
This works fine, when the script is launched by the user.
However when launched in the unittest (python setup.py test), the result is as follows:
test0 (testgui.Tests_GUI) … event send
FAIL
testgui.py (624 Bytes)
customevent_unittest.py (1.27 KB)
setup.py (160 Bytes)
···
======================================================================
FAIL: test0 (testgui.Tests_GUI)
Traceback (most recent call last):
File “/home/boudinec/devel/Allobrogia/trunk/tests_wx/customevent/testgui.py”, line 21, in test0
self.assertEqual(self.frame.text.GetLabel(),“event Ok”)
AssertionError: u’’ != ‘event Ok’
The
line test0 (testgui.Tests_GUI) … event send means that when the EVT_COMMAND_BUTTON_CLICKED is processed, OnButton is called and the custom event posted.
However, the fact that the tests fails means that the custom event is not caught by the main frame.
Is is possible to unittest custom events?
Regards
Cedric