File: OptionMenu_test.py

package info (click to toggle)
python-pmw 2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,968 kB
  • sloc: python: 42,737; makefile: 4
file content (53 lines) | stat: -rw-r--r-- 1,599 bytes parent folder | download | duplicates (2)
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
import Tkinter
import Test
import Pmw

Test.initialise()

c = Pmw.OptionMenu

kw_1 = {
    'labelpos' : 'nw',
    'label_text' : 'Option Menu:',
    'items' : ('Chips', 'Lollies', 'Junk', 'More junk'),
    'initialitem' : 1,
}
tests_1 = (
  (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}),
  (Test.num_options, (), 6),
  (c.getcurselection, (), 'Lollies'),
  (c.index, 'Junk', 2),
  (c.index, 'Nowhere', 'ValueError: bad index "Nowhere": must be ' +
    'a name, a number, Pmw.END or Pmw.SELECT'),
  (c.index, Pmw.END, 3),
  (c.index, Pmw.SELECT, 1),
  (c.index, 1, 1),
  (c.invoke, 'Chips'),
  (c.getcurselection, (), 'Chips'),
  ('command', Test.callback1),
  (c.invoke, (), 'Chips'),
  (c.invoke, 'Lollies', 'Lollies'),
  (c.getcurselection, (), 'Lollies'),
  ('hull_background', 'yellow'),
  ('hull_show', 'X', 'TclError: unknown option "-show"'),
  (c.index, Pmw.SELECT, 1),
  (c.setitems, (('Chips', 'Junk', 'Lollies', 'More junk'),)),
  (c.index, Pmw.SELECT, 2),
  (c.setitems, (('Fruit', 'Vegetables', 'Cereals', 'Legumes'),)),
  (c.index, Pmw.SELECT, 0),
  (c.getcurselection, (), 'Fruit'),
  (c.setitems, (('Vegetables', 'Cereals', 'Legumes'), Pmw.END)),
  (c.getcurselection, (), 'Legumes'),
  (c.index, 'Vegetables', 0),
  (c.invoke, 'Legumes', 'Legumes'),
  ('hull_cursor', 'gumby'),
  ('label_foreground', 'Green'),
  ('label_foreground', 'Black'),
  ('label_highlightcolor', 'Red'),
  ('label_text', 'Label'),
)

testData = ((c, ((tests_1, kw_1),)),)

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