wxpython, pywinauto and unittest problem

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

wxpython, pywinauto and unittest problem

Dennis Carachiola
I have an odd situation.

I am unittesting a wxPython gui using pyWinAuto.

I have (1) a test_dialog class; (2) a testcase class which includes (a) a setUp, (b) tearDown, (c) test1 and (d) test2 methods,  In addition, I have a standalone (meaning not in any class) 'display_gui' function which builds the gui and enters the wxPython mainloop.  Before starting the unittesting, I generate a pyWinAuto object, 'pwa_dlg', to point to the gui, once displayed.

The setUp method generates a gui thread and uses the display_gui function as the target, thus displaying the gui in that thread.

The test1 and test2 functions do nothing.

The tearDown function uses the pyWinAuto dlg.Close() method to close the gui.
(test code file attached)
-------------------------------------------------------------------------------------------------------

The setUp, test1, and tearDown work fine, with a correct return from the mainloop.

The setUp, and test2 also work fine.

However, entering tearDown the second time and attempting to close the dialog this time, I get the error:
---------  wxAssertionError: C++ assertion "wxThread::IsMain()" failed at ..\..\src\msw\evtloop.cpp(182) in wxGUIEventLoop::Dispatch(): only the main thread can process Windows messages ------------.

I also get a wxWidget Debug Alert dialog box:
---------- ..\..\src\common\socket.cpp(767): assert "wxIsMainThread()" failed in wxSocketBase::IsInitialized(): unsafe to call from other threads [in thread 1630].  ----------
In addition, there is no return from the mainloop

I don't understand why the teardown function works perfectly the first time through, but not the second time through.  The first time through, it seems the threads behave one way while the second time through, the threads behave differently.

Does anyone have any thoughts?

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

test code (1K) Download Attachment
Loading...