forked from svn2github/wxPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestRadioButton.py
More file actions
67 lines (57 loc) · 2.2 KB
/
Copy pathtestRadioButton.py
File metadata and controls
67 lines (57 loc) · 2.2 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
57
58
59
60
61
62
63
64
65
66
67
"""Unit tests for wx.RadioButton.
Methods yet to test:
__init__, Create"""
import unittest
import wx
import testControl
class RadioButtonTest(testControl.ControlTest):
def setUp(self):
self.frame = wx.Frame(parent=None, id=wx.ID_ANY)
self.label = "Label of the RadioButton!"
self.testControl = wx.RadioButton(parent=self.frame, label=self.label,
style=wx.RB_GROUP)
def testDifferentGroupsToggle(self):
""" """
one = [ wx.RadioButton(self.frame, style=wx.RB_GROUP),
wx.RadioButton(self.frame),
wx.RadioButton(self.frame) ]
two = [ wx.RadioButton(self.frame, style=wx.RB_GROUP),
wx.RadioButton(self.frame),
wx.RadioButton(self.frame) ]
for i in range(len(one)):
one[i].SetValue(True)
for j in range(len(two)):
two[j].SetValue(True)
for rb in two:
if rb == two[j]:
self.assert_(rb.GetValue())
else:
self.assert_(not rb.GetValue())
def testLabel(self):
"""GetLabel"""
# Overrides previous testLabel method
self.assertEquals(self.label, self.testControl.GetLabel())
def testToggle(self):
""" """
a = wx.RadioButton(self.frame, label="a")
b = wx.RadioButton(self.frame, label="b")
self.testControl.SetValue(True)
self.assert_(self.testControl.GetValue())
for rad in (a,b):
self.assert_(not rad.GetValue())
a.SetValue(True)
self.assert_(a.GetValue())
for rad in (b,self.testControl):
self.assert_(not rad.GetValue())
b.SetValue(True)
self.assert_(b.GetValue())
for rad in (a,self.testControl):
self.assert_(not rad.GetValue())
def testValue(self):
"""SetValue, GetValue"""
self.testControl.SetValue(True)
self.assert_(self.testControl.GetValue())
self.testControl.SetValue(False)
self.assert_(not self.testControl.GetValue())
if __name__ == '__main__':
unittest.main()