Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_curses.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | b36cb4602e21 |
| children | aff0bdab358e |
| rev | line source |
|---|---|
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
1 # |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
2 # Test script for the curses module |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
3 # |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
4 # This script doesn't actually display anything very coherent. but it |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
5 # does call every method and function. |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
6 # |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
7 # Functions not tested: {def,reset}_{shell,prog}_mode, getch(), getstr(), |
|
36263
3c030edff985
SF bug #1400822, Extended version of _curses over{lay,write} does not work
Neal Norwitz <nnorwitz@gmail.com>
parents:
36251
diff
changeset
|
8 # init_color() |
|
3c030edff985
SF bug #1400822, Extended version of _curses over{lay,write} does not work
Neal Norwitz <nnorwitz@gmail.com>
parents:
36251
diff
changeset
|
9 # Only called, not tested: getmouse(), ungetmouse() |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
10 # |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
11 |
|
52491
f4c5e3a64be2
Change more tests to use import_module for the modules that
R. David Murray <rdmurray@bitdance.com>
parents:
52355
diff
changeset
|
12 import sys, tempfile, os |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
13 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
14 # Optionally test curses module. This currently requires that the |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
15 # 'curses' resource be given on the regrtest command line using the -u |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
16 # option. If not available, nothing after this line will be executed. |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
17 |
|
54655
b8d160ad1c92
Missing import in test_curses, uncovered by some buildbots.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
52491
diff
changeset
|
18 import unittest |
|
52491
f4c5e3a64be2
Change more tests to use import_module for the modules that
R. David Murray <rdmurray@bitdance.com>
parents:
52355
diff
changeset
|
19 from test.test_support import requires, import_module |
|
36214
c9da08d482c3
initscr() will exit if there's an error. Try to catch the obvious failure
Neal Norwitz <nnorwitz@gmail.com>
parents:
36197
diff
changeset
|
20 requires('curses') |
|
52491
f4c5e3a64be2
Change more tests to use import_module for the modules that
R. David Murray <rdmurray@bitdance.com>
parents:
52355
diff
changeset
|
21 curses = import_module('curses') |
|
f4c5e3a64be2
Change more tests to use import_module for the modules that
R. David Murray <rdmurray@bitdance.com>
parents:
52355
diff
changeset
|
22 curses.panel = import_module('curses.panel') |
|
36214
c9da08d482c3
initscr() will exit if there's an error. Try to catch the obvious failure
Neal Norwitz <nnorwitz@gmail.com>
parents:
36197
diff
changeset
|
23 |
|
58980
0ed193769a5f
Merged revisions 78281 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
57106
diff
changeset
|
24 |
|
36214
c9da08d482c3
initscr() will exit if there's an error. Try to catch the obvious failure
Neal Norwitz <nnorwitz@gmail.com>
parents:
36197
diff
changeset
|
25 # XXX: if newterm was supported we could use it instead of initscr and not exit |
|
c9da08d482c3
initscr() will exit if there's an error. Try to catch the obvious failure
Neal Norwitz <nnorwitz@gmail.com>
parents:
36197
diff
changeset
|
26 term = os.environ.get('TERM') |
|
c9da08d482c3
initscr() will exit if there's an error. Try to catch the obvious failure
Neal Norwitz <nnorwitz@gmail.com>
parents:
36197
diff
changeset
|
27 if not term or term == 'unknown': |
|
52355
228cfb6e2900
fix incorrect auto-translation of TestSkipped -> unittest.SkipTest
Benjamin Peterson <benjamin@python.org>
parents:
52353
diff
changeset
|
28 raise unittest.SkipTest, "$TERM=%r, calling initscr() may cause exit" % term |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
29 |
|
37467
1f109a4953c6
cygwin's curses support isn't up to scratch to run the tests.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
36274
diff
changeset
|
30 if sys.platform == "cygwin": |
|
52355
228cfb6e2900
fix incorrect auto-translation of TestSkipped -> unittest.SkipTest
Benjamin Peterson <benjamin@python.org>
parents:
52353
diff
changeset
|
31 raise unittest.SkipTest("cygwin's curses mostly just hangs") |
|
37467
1f109a4953c6
cygwin's curses support isn't up to scratch to run the tests.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
36274
diff
changeset
|
32 |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
33 def window_funcs(stdscr): |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
34 "Test the methods of windows" |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
35 win = curses.newwin(10,10) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
36 win = curses.newwin(5,5, 5,5) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
37 win2 = curses.newwin(15,15, 5,5) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
38 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
39 for meth in [stdscr.addch, stdscr.addstr]: |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
40 for args in [('a'), ('a', curses.A_BOLD), |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
41 (4,4, 'a'), (5,5, 'a', curses.A_BOLD)]: |
|
28513
90c77b8af1a4
SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents:
24364
diff
changeset
|
42 meth(*args) |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
43 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
44 for meth in [stdscr.box, stdscr.clear, stdscr.clrtobot, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
45 stdscr.clrtoeol, stdscr.cursyncup, stdscr.delch, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
46 stdscr.deleteln, stdscr.erase, stdscr.getbegyx, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
47 stdscr.getbkgd, stdscr.getkey, stdscr.getmaxyx, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
48 stdscr.getparyx, stdscr.getyx, stdscr.inch, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
49 stdscr.insertln, stdscr.instr, stdscr.is_wintouched, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
50 win.noutrefresh, stdscr.redrawwin, stdscr.refresh, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
51 stdscr.standout, stdscr.standend, stdscr.syncdown, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
52 stdscr.syncup, stdscr.touchwin, stdscr.untouchwin]: |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
53 meth() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
54 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
55 stdscr.addnstr('1234', 3) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
56 stdscr.addnstr('1234', 3, curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
57 stdscr.addnstr(4,4, '1234', 3) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
58 stdscr.addnstr(5,5, '1234', 3, curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
59 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
60 stdscr.attron(curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
61 stdscr.attroff(curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
62 stdscr.attrset(curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
63 stdscr.bkgd(' ') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
64 stdscr.bkgd(' ', curses.A_REVERSE) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
65 stdscr.bkgdset(' ') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
66 stdscr.bkgdset(' ', curses.A_REVERSE) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
67 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
68 win.border(65, 66, 67, 68, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
69 69, 70, 71, 72) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
70 win.border('|', '!', '-', '_', |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
71 '+', '\\', '#', '/') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
72 try: |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
73 win.border(65, 66, 67, 68, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
74 69, [], 71, 72) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
75 except TypeError: |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
76 pass |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
77 else: |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
78 raise RuntimeError, "Expected win.border() to raise TypeError" |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
79 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
80 stdscr.clearok(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
81 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
82 win4 = stdscr.derwin(2,2) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
83 win4 = stdscr.derwin(1,1, 5,5) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
84 win4.mvderwin(9,9) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
85 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
86 stdscr.echochar('a') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
87 stdscr.echochar('a', curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
88 stdscr.hline('-', 5) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
89 stdscr.hline('-', 5, curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
90 stdscr.hline(1,1,'-', 5) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
91 stdscr.hline(1,1,'-', 5, curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
92 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
93 stdscr.idcok(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
94 stdscr.idlok(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
95 stdscr.immedok(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
96 stdscr.insch('c') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
97 stdscr.insdelln(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
98 stdscr.insnstr('abc', 3) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
99 stdscr.insnstr('abc', 3, curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
100 stdscr.insnstr(5, 5, 'abc', 3) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
101 stdscr.insnstr(5, 5, 'abc', 3, curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
102 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
103 stdscr.insstr('def') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
104 stdscr.insstr('def', curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
105 stdscr.insstr(5, 5, 'def') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
106 stdscr.insstr(5, 5, 'def', curses.A_BOLD) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
107 stdscr.is_linetouched(0) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
108 stdscr.keypad(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
109 stdscr.leaveok(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
110 stdscr.move(3,3) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
111 win.mvwin(2,2) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
112 stdscr.nodelay(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
113 stdscr.notimeout(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
114 win2.overlay(win) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
115 win2.overwrite(win) |
|
36263
3c030edff985
SF bug #1400822, Extended version of _curses over{lay,write} does not work
Neal Norwitz <nnorwitz@gmail.com>
parents:
36251
diff
changeset
|
116 win2.overlay(win, 1, 2, 3, 3, 2, 1) |
|
3c030edff985
SF bug #1400822, Extended version of _curses over{lay,write} does not work
Neal Norwitz <nnorwitz@gmail.com>
parents:
36251
diff
changeset
|
117 win2.overwrite(win, 1, 2, 3, 3, 2, 1) |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
118 stdscr.redrawln(1,2) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
119 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
120 stdscr.scrollok(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
121 stdscr.scroll() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
122 stdscr.scroll(2) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
123 stdscr.scroll(-3) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
124 |
|
35092
68bce68c8f93
[Patch #1005892 from Alexandr Zamaraev] Fix two errors in the curses test suite
Andrew M. Kuchling <amk@amk.ca>
parents:
32996
diff
changeset
|
125 stdscr.move(12, 2) |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
126 stdscr.setscrreg(10,15) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
127 win3 = stdscr.subwin(10,10) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
128 win3 = stdscr.subwin(10,10, 5,5) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
129 stdscr.syncok(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
130 stdscr.timeout(5) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
131 stdscr.touchline(5,5) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
132 stdscr.touchline(5,5,0) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
133 stdscr.vline('a', 3) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
134 stdscr.vline('a', 3, curses.A_STANDOUT) |
|
41427
40110d06e82a
Add window.chgat() method, submitted via e-mail by Fabian Kreutz
Andrew M. Kuchling <amk@amk.ca>
parents:
41133
diff
changeset
|
135 stdscr.chgat(5, 2, 3, curses.A_BLINK) |
|
40110d06e82a
Add window.chgat() method, submitted via e-mail by Fabian Kreutz
Andrew M. Kuchling <amk@amk.ca>
parents:
41133
diff
changeset
|
136 stdscr.chgat(3, curses.A_BOLD) |
|
40110d06e82a
Add window.chgat() method, submitted via e-mail by Fabian Kreutz
Andrew M. Kuchling <amk@amk.ca>
parents:
41133
diff
changeset
|
137 stdscr.chgat(5, 8, curses.A_UNDERLINE) |
|
40110d06e82a
Add window.chgat() method, submitted via e-mail by Fabian Kreutz
Andrew M. Kuchling <amk@amk.ca>
parents:
41133
diff
changeset
|
138 stdscr.chgat(curses.A_BLINK) |
|
40110d06e82a
Add window.chgat() method, submitted via e-mail by Fabian Kreutz
Andrew M. Kuchling <amk@amk.ca>
parents:
41133
diff
changeset
|
139 stdscr.refresh() |
|
40110d06e82a
Add window.chgat() method, submitted via e-mail by Fabian Kreutz
Andrew M. Kuchling <amk@amk.ca>
parents:
41133
diff
changeset
|
140 |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
141 stdscr.vline(1,1, 'a', 3) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
142 stdscr.vline(1,1, 'a', 3, curses.A_STANDOUT) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
143 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
144 if hasattr(curses, 'resize'): |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
145 stdscr.resize() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
146 if hasattr(curses, 'enclose'): |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
147 stdscr.enclose() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
148 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
149 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
150 def module_funcs(stdscr): |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
151 "Test module-level functions" |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
152 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
153 for func in [curses.baudrate, curses.beep, curses.can_change_color, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
154 curses.cbreak, curses.def_prog_mode, curses.doupdate, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
155 curses.filter, curses.flash, curses.flushinp, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
156 curses.has_colors, curses.has_ic, curses.has_il, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
157 curses.isendwin, curses.killchar, curses.longname, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
158 curses.nocbreak, curses.noecho, curses.nonl, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
159 curses.noqiflush, curses.noraw, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
160 curses.reset_prog_mode, curses.termattrs, |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
161 curses.termname, curses.erasechar, curses.getsyx]: |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
162 func() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
163 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
164 # Functions that actually need arguments |
| 32996 | 165 if curses.tigetstr("cnorm"): |
| 166 curses.curs_set(1) | |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
167 curses.delay_output(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
168 curses.echo() ; curses.echo(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
169 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
170 f = tempfile.TemporaryFile() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
171 stdscr.putwin(f) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
172 f.seek(0) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
173 curses.getwin(f) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
174 f.close() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
175 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
176 curses.halfdelay(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
177 curses.intrflush(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
178 curses.meta(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
179 curses.napms(100) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
180 curses.newpad(50,50) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
181 win = curses.newwin(5,5) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
182 win = curses.newwin(5,5, 1,1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
183 curses.nl() ; curses.nl(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
184 curses.putp('abc') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
185 curses.qiflush() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
186 curses.raw() ; curses.raw(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
187 curses.setsyx(5,5) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
188 curses.tigetflag('hc') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
189 curses.tigetnum('co') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
190 curses.tigetstr('cr') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
191 curses.tparm('cr') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
192 curses.typeahead(sys.__stdin__.fileno()) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
193 curses.unctrl('a') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
194 curses.ungetch('a') |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
195 curses.use_env(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
196 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
197 # Functions only available on a few platforms |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
198 if curses.has_colors(): |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
199 curses.start_color() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
200 curses.init_pair(2, 1,1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
201 curses.color_content(1) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
202 curses.color_pair(2) |
|
35092
68bce68c8f93
[Patch #1005892 from Alexandr Zamaraev] Fix two errors in the curses test suite
Andrew M. Kuchling <amk@amk.ca>
parents:
32996
diff
changeset
|
203 curses.pair_content(curses.COLOR_PAIRS - 1) |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
204 curses.pair_number(0) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
205 |
| 32996 | 206 if hasattr(curses, 'use_default_colors'): |
| 207 curses.use_default_colors() | |
|
30140
f3654c5ada94
[Patch #739124] Add use_default_colors() to curses module
Andrew M. Kuchling <amk@amk.ca>
parents:
28513
diff
changeset
|
208 |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
209 if hasattr(curses, 'keyname'): |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
210 curses.keyname(13) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
211 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
212 if hasattr(curses, 'has_key'): |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
213 curses.has_key(13) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
214 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
215 if hasattr(curses, 'getmouse'): |
|
37507
5b119f256cde
In some environments (under screen, in a chroot) curses doesn't support
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37467
diff
changeset
|
216 (availmask, oldmask) = curses.mousemask(curses.BUTTON1_PRESSED) |
|
5b119f256cde
In some environments (under screen, in a chroot) curses doesn't support
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37467
diff
changeset
|
217 # availmask indicates that mouse stuff not available. |
|
5b119f256cde
In some environments (under screen, in a chroot) curses doesn't support
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37467
diff
changeset
|
218 if availmask != 0: |
|
5b119f256cde
In some environments (under screen, in a chroot) curses doesn't support
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37467
diff
changeset
|
219 curses.mouseinterval(10) |
|
5b119f256cde
In some environments (under screen, in a chroot) curses doesn't support
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37467
diff
changeset
|
220 # just verify these don't cause errors |
|
63943
4a5ad918f7af
Issue #8433: Fix test_curses failure caused by newer versions of
Mark Dickinson <dickinsm@gmail.com>
parents:
62353
diff
changeset
|
221 curses.ungetmouse(0, 0, 0, 0, curses.BUTTON1_PRESSED) |
|
37507
5b119f256cde
In some environments (under screen, in a chroot) curses doesn't support
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37467
diff
changeset
|
222 m = curses.getmouse() |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
223 |
|
38876
4a766024043a
Patch #1506645: add Python wrappers for the curses functions
Walter Dörwald <walter@livinglogic.de>
parents:
37507
diff
changeset
|
224 if hasattr(curses, 'is_term_resized'): |
|
4a766024043a
Patch #1506645: add Python wrappers for the curses functions
Walter Dörwald <walter@livinglogic.de>
parents:
37507
diff
changeset
|
225 curses.is_term_resized(*stdscr.getmaxyx()) |
|
4a766024043a
Patch #1506645: add Python wrappers for the curses functions
Walter Dörwald <walter@livinglogic.de>
parents:
37507
diff
changeset
|
226 if hasattr(curses, 'resizeterm'): |
|
4a766024043a
Patch #1506645: add Python wrappers for the curses functions
Walter Dörwald <walter@livinglogic.de>
parents:
37507
diff
changeset
|
227 curses.resizeterm(*stdscr.getmaxyx()) |
|
4a766024043a
Patch #1506645: add Python wrappers for the curses functions
Walter Dörwald <walter@livinglogic.de>
parents:
37507
diff
changeset
|
228 if hasattr(curses, 'resize_term'): |
|
4a766024043a
Patch #1506645: add Python wrappers for the curses functions
Walter Dörwald <walter@livinglogic.de>
parents:
37507
diff
changeset
|
229 curses.resize_term(*stdscr.getmaxyx()) |
|
4a766024043a
Patch #1506645: add Python wrappers for the curses functions
Walter Dörwald <walter@livinglogic.de>
parents:
37507
diff
changeset
|
230 |
|
30233
c47f5ac8b06d
Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents:
30140
diff
changeset
|
231 def unit_tests(): |
|
c47f5ac8b06d
Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents:
30140
diff
changeset
|
232 from curses import ascii |
|
c47f5ac8b06d
Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents:
30140
diff
changeset
|
233 for ch, expected in [('a', 'a'), ('A', 'A'), |
|
c47f5ac8b06d
Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents:
30140
diff
changeset
|
234 (';', ';'), (' ', ' '), |
|
30235
7f34652d7161
Add tests for meta- bit set
Andrew M. Kuchling <amk@amk.ca>
parents:
30233
diff
changeset
|
235 ('\x7f', '^?'), ('\n', '^J'), ('\0', '^@'), |
|
7f34652d7161
Add tests for meta- bit set
Andrew M. Kuchling <amk@amk.ca>
parents:
30233
diff
changeset
|
236 # Meta-bit characters |
|
7f34652d7161
Add tests for meta- bit set
Andrew M. Kuchling <amk@amk.ca>
parents:
30233
diff
changeset
|
237 ('\x8a', '!^J'), ('\xc1', '!A'), |
|
7f34652d7161
Add tests for meta- bit set
Andrew M. Kuchling <amk@amk.ca>
parents:
30233
diff
changeset
|
238 ]: |
|
30233
c47f5ac8b06d
Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents:
30140
diff
changeset
|
239 if ascii.unctrl(ch) != expected: |
|
c47f5ac8b06d
Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents:
30140
diff
changeset
|
240 print 'curses.unctrl fails on character', repr(ch) |
|
31389
aca1ce1b4b61
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
30235
diff
changeset
|
241 |
|
30233
c47f5ac8b06d
Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents:
30140
diff
changeset
|
242 |
|
36251
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
36214
diff
changeset
|
243 def test_userptr_without_set(stdscr): |
|
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
36214
diff
changeset
|
244 w = curses.newwin(10, 10) |
|
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
36214
diff
changeset
|
245 p = curses.panel.new_panel(w) |
|
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
36214
diff
changeset
|
246 # try to access userptr() before calling set_userptr() -- segfaults |
|
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
36214
diff
changeset
|
247 try: |
|
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
36214
diff
changeset
|
248 p.userptr() |
|
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
36214
diff
changeset
|
249 raise RuntimeError, 'userptr should fail since not set' |
|
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
36214
diff
changeset
|
250 except curses.panel.error: |
|
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
36214
diff
changeset
|
251 pass |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
252 |
|
41039
3ac24c0110e9
Patch for bug #1633621: if curses.resizeterm() or
Walter Dörwald <walter@livinglogic.de>
parents:
38876
diff
changeset
|
253 def test_resize_term(stdscr): |
|
3ac24c0110e9
Patch for bug #1633621: if curses.resizeterm() or
Walter Dörwald <walter@livinglogic.de>
parents:
38876
diff
changeset
|
254 if hasattr(curses, 'resizeterm'): |
|
3ac24c0110e9
Patch for bug #1633621: if curses.resizeterm() or
Walter Dörwald <walter@livinglogic.de>
parents:
38876
diff
changeset
|
255 lines, cols = curses.LINES, curses.COLS |
|
3ac24c0110e9
Patch for bug #1633621: if curses.resizeterm() or
Walter Dörwald <walter@livinglogic.de>
parents:
38876
diff
changeset
|
256 curses.resizeterm(lines - 1, cols + 1) |
|
41133
01355124ce40
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
41039
diff
changeset
|
257 |
|
41039
3ac24c0110e9
Patch for bug #1633621: if curses.resizeterm() or
Walter Dörwald <walter@livinglogic.de>
parents:
38876
diff
changeset
|
258 if curses.LINES != lines - 1 or curses.COLS != cols + 1: |
|
3ac24c0110e9
Patch for bug #1633621: if curses.resizeterm() or
Walter Dörwald <walter@livinglogic.de>
parents:
38876
diff
changeset
|
259 raise RuntimeError, "Expected resizeterm to update LINES and COLS" |
|
3ac24c0110e9
Patch for bug #1633621: if curses.resizeterm() or
Walter Dörwald <walter@livinglogic.de>
parents:
38876
diff
changeset
|
260 |
|
59018
d7c3377f8a7b
Merged revisions 75066 via svnmerge from
Andrew M. Kuchling <amk@amk.ca>
parents:
58980
diff
changeset
|
261 def test_issue6243(stdscr): |
|
d7c3377f8a7b
Merged revisions 75066 via svnmerge from
Andrew M. Kuchling <amk@amk.ca>
parents:
58980
diff
changeset
|
262 curses.ungetch(1025) |
|
d7c3377f8a7b
Merged revisions 75066 via svnmerge from
Andrew M. Kuchling <amk@amk.ca>
parents:
58980
diff
changeset
|
263 stdscr.getkey() |
|
d7c3377f8a7b
Merged revisions 75066 via svnmerge from
Andrew M. Kuchling <amk@amk.ca>
parents:
58980
diff
changeset
|
264 |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
265 def main(stdscr): |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
266 curses.savetty() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
267 try: |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
268 module_funcs(stdscr) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
269 window_funcs(stdscr) |
|
36251
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
36214
diff
changeset
|
270 test_userptr_without_set(stdscr) |
|
41039
3ac24c0110e9
Patch for bug #1633621: if curses.resizeterm() or
Walter Dörwald <walter@livinglogic.de>
parents:
38876
diff
changeset
|
271 test_resize_term(stdscr) |
|
59018
d7c3377f8a7b
Merged revisions 75066 via svnmerge from
Andrew M. Kuchling <amk@amk.ca>
parents:
58980
diff
changeset
|
272 test_issue6243(stdscr) |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
273 finally: |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
274 curses.resetty() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
275 |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
276 if __name__ == '__main__': |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
277 curses.wrapper(main) |
|
30233
c47f5ac8b06d
Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents:
30140
diff
changeset
|
278 unit_tests() |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
279 else: |
|
57090
bb37c7c26fa4
It turns out test_curses can fail in a 2.6 buildbot because stdout is not
R. David Murray <rdmurray@bitdance.com>
parents:
45516
diff
changeset
|
280 if not sys.__stdout__.isatty(): |
|
56615
f30667cd4043
Only run test_curses when sys.__stdout__ is a tty. This eliminates the
R. David Murray <rdmurray@bitdance.com>
parents:
56224
diff
changeset
|
281 raise unittest.SkipTest("sys.__stdout__ is not a tty") |
|
45516
f88bebeeb673
Move .setupterm() output so that we don't try to call endwin() if it fails
Andrew M. Kuchling <amk@amk.ca>
parents:
41427
diff
changeset
|
282 # testing setupterm() inside initscr/endwin |
|
f88bebeeb673
Move .setupterm() output so that we don't try to call endwin() if it fails
Andrew M. Kuchling <amk@amk.ca>
parents:
41427
diff
changeset
|
283 # causes terminal breakage |
|
f88bebeeb673
Move .setupterm() output so that we don't try to call endwin() if it fails
Andrew M. Kuchling <amk@amk.ca>
parents:
41427
diff
changeset
|
284 curses.setupterm(fd=sys.__stdout__.fileno()) |
|
20610
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
285 try: |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
286 stdscr = curses.initscr() |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
287 main(stdscr) |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
288 finally: |
|
7dcc8a28133a
Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
289 curses.endwin() |
|
30233
c47f5ac8b06d
Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents:
30140
diff
changeset
|
290 unit_tests() |
