forked from svn2github/wxPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestControl.py
More file actions
56 lines (45 loc) · 1.99 KB
/
Copy pathtestControl.py
File metadata and controls
56 lines (45 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Unit tests for wx.Control.
Methods yet to test for wx.Control:
Command, Create, GetAlignment"""
import unittest
import wx
import wxtest
import testWindow
class ControlTest(testWindow.WindowTest):
def __init__(self, arg):
# superclass setup
super(ControlTest,self).__init__(arg)
self.name = "Name of Control"
self.label_with_mnemonic = "Hello &World"
self.label_without_mnemonic = "Hello World"
def setUp(self):
self.frame = wx.Frame(parent=None, id=wx.ID_ANY)
self.testControl = wx.Control(parent=self.frame, id=wx.ID_ANY)
def testAllControlsNeedParents(self):
"""__init__"""
'''The assumption here is that all wx.Controls and subclasses need to have
parents. Some platforms (GTK) do not enforce this at object creation
time; this is to be considered an implementation detail.
"wxWidgets does require that non top-level windows have a parent,
it's just not enforced in debug mode on wxGTK like the others do."
For more information, see
http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi?12:mss:3440:fjmhidphpdnbhoobomhi
UPDATE: This may have more to do with the 'wx-assertions-on' flag than GTK itself.
More research must be done.
'''
class_under_test = type(self.testControl)
if wxtest.ASSERTIONS_ON:
self.assertRaises(wx.PyAssertionError, class_under_test, None)
else:
class_under_test(None)
def testGetName(self):
"""GetName"""
self.testControl = type(self.testControl)(parent=self.frame, name=self.name)
self.assertEquals(self.name, self.testControl.GetName())
def testLabelText(self):
"""SetLabel, GetLabelText"""
# GetLabelText removes the mnemonics
self.testControl.SetLabel(self.label_with_mnemonic)
self.assertEquals(self.label_without_mnemonic, self.testControl.GetLabelText())
if __name__ == '__main__':
unittest.main()