469,275 Members | 1,588 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

How to test wxPython by unittest

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

Mar 21 '06 #1
1 1880
sillyemperor:
I was a new guy of Python,when i want to test my wxPython app by
unittest,it couldn`t work.I fund a stubmaker.py 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.textCtrl.AppendText('whatever')
self.assertEqual('whatever', self.textCtrl.GetValue())

def testAppendTextTwice(self):
self.textCtrl.AppendText('whatever')
self.textCtrl.AppendText('and then some')
self.assertEqual('whateverand then some',
self.textCtrl.GetValue())
if __name__ == '__main__':
unittest.main()


Cheers, Frank
Mar 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jan Decaluwe | last post: by
reply views Thread by Remy Blank | last post: by
8 posts views Thread by StepH | last post: by
41 posts views Thread by Roy Smith | last post: by
4 posts views Thread by ajikoe | last post: by
6 posts views Thread by Ben Finney | last post: by
5 posts views Thread by Sakcee | last post: by
27 posts views Thread by Josh | last post: by
2 posts views Thread by Podi | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.