]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-05/testEventExample.py
don't use strlen() to verify the length of the string as it can contain embedded...
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-05 / testEventExample.py
1 import unittest
2 import modelExample
3 import wx
4
5 class TestExample(unittest.TestCase):
6
7 def setUp(self):
8 self.app = wx.PySimpleApp()
9 self.frame = modelExample.ModelExample(parent=None, id=-1)
10
11 def tearDown(self):
12 self.frame.Destroy()
13
14 def testModel(self):
15 self.frame.OnBarney(None)
16 self.assertEqual("Barney", self.frame.model.first,
17 msg="First is wrong")
18 self.assertEqual("Rubble", self.frame.model.last)
19
20 def testEvent(self):
21 panel = self.frame.GetChildren()[0]
22 for each in panel.GetChildren():
23 if each.GetLabel() == "Wilmafy":
24 wilma = each
25 break
26 event = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, wilma.GetId())
27 wilma.GetEventHandler().ProcessEvent(event)
28 self.assertEqual("Wilma", self.frame.model.first)
29 self.assertEqual("Flintstone", self.frame.model.last)
30
31 def suite():
32 suite = unittest.makeSuite(TestExample, 'test')
33 return suite
34
35 if __name__ == '__main__':
36 unittest.main(defaultTest='suite')
37