File: RadioSelect_test.py

package info (click to toggle)
python-pmw 1.2-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,024 kB
  • ctags: 3,802
  • sloc: python: 17,143; makefile: 41
file content (112 lines) | stat: -rw-r--r-- 3,407 bytes parent folder | download | duplicates (5)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import Tkinter
import Test
import Pmw

Test.initialise()

if Tkinter.TkVersion >= 8.4:
  expected1 = 'TclError: bad relief "bogus": must be '
else:
  expected1 = 'TclError: bad relief type "bogus": must be '

c = Pmw.RadioSelect

kw_1 = {'labelpos' : 'nw', 'label_text' : 'Radio Select:'}
tests_1 = (
  (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}),
  (Test.num_options, (), 8),
  (c.index, Pmw.END, 'ValueError: RadioSelect has no buttons'),
  (c.add, ('Fruit',), Tkinter.Button),
  (c.add, ('Vegetables',), Tkinter.Button),
  (c.add, ('CornFlakes',), {'text': 'Cereals'}, Tkinter.Button),
  (c.add, ('Legumes',), Tkinter.Button),
  (c.add, ('Legumes',), 'ValueError: button "Legumes" already exists'),
  (c.index, 0, 0),
  (c.index, Pmw.END, 3),
  (c.index, 'Vegetables', 1),
  (c.index, 'Fruit', 0),
  (c.index, 12, 'ValueError: index "12" is out of range'),
  (c.index, 'bogus', 'ValueError: bad index "bogus": ' + \
      'must be a name, a number or Pmw.END'),
  ('hull_background', 'yellow'),
  ('hull_show', 'X', 'TclError: unknown option "-show"'),
  ('frame_relief', 'raised'),
  ('frame_borderwidth', 4),
  ('frame_borderwidth', 2),
  ('command', Test.callback1),
  (c.invoke, 'Vegetables', 'Vegetables'),
  ('hull_cursor', 'gumby'),
  ('Button_state', 'disabled'),
  ('Button_background', 'Green'),
  ('Button_cursor', 'watch'),
  ('Button_background', 'grey85'),
  ('label_foreground', 'Green'),
  ('label_foreground', 'Black'),
  ('label_highlightcolor', 'Red'),
  ('Fruit_background', 'red'),
  ('Vegetables_background', 'green'),
  ('CornFlakes_background', 'yellow'),
  ('Legumes_background', 'brown'),
  ('Legumes_foreground', 'white'),
  (c.add, ('Foo',), Tkinter.Button),
  ('label_text', 'Label'),
  ('frame_relief', 'sunken'),
  ('frame_relief', 'bogus', expected1 + Test.reliefs),
  (c.deleteall, ()),
)

kw_2 = {
    'labelpos' : 'nw',
    'label_text' : 'Multiple:',
    'selectmode' : 'multiple',
}
tests_2 = (
  (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}),
  (c.add, ('Fruit',), Tkinter.Button),
  (c.add, ('Vegetables',), Tkinter.Button),
  (c.add, ('CornFlakes',), {'text': 'Cereals'}, Tkinter.Button),
  (c.add, ('Legumes',), Tkinter.Button),
  ('command', Test.callback2),
  (c.getcurselection, (), ()),
  (c.invoke, 'Vegetables', ('Vegetables', 1)),
  (c.getcurselection, (), ('Vegetables',)),
  (c.invoke, 'Legumes', ('Legumes', 1)),
  (c.getcurselection, (), ('Vegetables', 'Legumes')),
  (c.invoke, 'Fruit', ('Fruit', 1)),
  (c.getcurselection, (), ('Vegetables', 'Legumes', 'Fruit')),
  (c.invoke, 'Legumes', ('Legumes', 0)),
  (c.getcurselection, (), ('Vegetables', 'Fruit')),
  (c.deleteall, ()),
  (c.add, ('Fruit',), Tkinter.Button),
  (c.add, ('Vegetables',), Tkinter.Button),
  (c.invoke, 'Vegetables', ('Vegetables', 1)),
  (c.getcurselection, (), ('Vegetables',)),
)

alltests = [
  (tests_1, kw_1),
  (tests_2, kw_2),
]


tests_3 = (
  (c.pack, (), {'padx' : 10, 'pady' : 10}),
  (c.add, ('Foo',), Tkinter.Button),
  (c.add, ('Bar',), Tkinter.Button),
)

poslist = ('nw', 'n', 'ne', 'en', 'e', 'es', 'se', 's', 'sw', 'ws', 'w', 'wn',)
for pos in poslist:
  kw_3 = {
    'labelpos' : pos,
    'orient' : 'vertical',
    'padx' : 20,
    'pady' : 20,
    'label_text' : 'Radio Select',
  }
  alltests.append((tests_3, kw_3))

testData = ((c, alltests),)

if __name__ == '__main__':
    Test.runTests(testData)