Python provides a unittest module for unit testing. This facility is often referred to as [http://pyunit.sourceforge.net/ PyUnit].
However, [http://pyunit.sourceforge.net/ PyUnit] cannot easily be used to test wxPython applications, primarily because of the interaction required to press buttons, select items, etc.
One approach to testing a wxPython app with unittest, is to replace wxPython common dialogs and user dialogs with code that simulates the actions of the dialogs, so that the remaining Python code can be tested. At the same time, the code for the dialogs is tested to verify it is bug-free.
A pair of modules that performs these functions is available - along with examples - at: http://www.vilchjo.lunarpages.com/Python/NDtestmaker/NDtestmaker.htm
This approach does not solve all the problems of unit testing wxPython apps. For example, packages are not supported, and some dialogs are not easily simulated. Nevertheless, for many applications, where wxPython is primarily a user front-end to Python code, this approach is sufficient.
At present, This approach has been tested on two small applications with good results. In both cases, wxPython applications have been tested in an automated fashion using unittest.
Bill Harris
We've also come across [http://groups.yahoo.com/group/extremeprogramming/files/PythonMock.zip PythonMock] (you will need to subscribe to the Extreme Programming group on Yahoo to get the file). It's a simple concept - using [http://www.mockobjects.com Mock Objects] to enable easy unit testing. Python Mock implements a class that can be passed to functions under test instead of a class used during standard operations. The Mock class records all function calls and the parameters passed to the functions.
Hugh Gibson