How to test wxPython by unittest

Frank Niessink frank at
Fri Mar 24 22:54:52 CET 2006

> I was a new guy of Python,when i want to test my wxPython app by
> unittest,it couldn`t work.I fund a but it only for
> wxDialog but all widgets.Can someone can tell me how test wxPython by
> unittest?Thanks

Here's a small example to get you started:

import unittest, wx

class TextCtrlTest(unittest.TestCase):
     def setUp(self):
         app = wx.App(0)
         frame = wx.Frame(None)
         self.textCtrl = wx.TextCtrl(frame)

     def testInitialContents(self):
         self.assertEqual('', self.textCtrl.GetValue())

     def testAppendText(self):
         self.assertEqual('whatever', self.textCtrl.GetValue())

     def testAppendTextTwice(self):
         self.textCtrl.AppendText('and then some')
         self.assertEqual('whateverand then some',

if __name__ == '__main__':

Cheers, Frank

More information about the Python-list mailing list