annotate Lib/test/test_curses.py @ 78069:a8aa77458e12 3.2

Add c_size_t and c_ssize_t to the ctypes summary table.
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 12 Jul 2012 20:31:50 +0200
parents 38f4a251608f
children 08f44eb760a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
52625
f84340886936 Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
R. David Murray <rdmurray@bitdance.com>
parents: 52389
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
54657
0480700553ab Merged revisions 73328 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 52625
diff changeset
18 import unittest
52625
f84340886936 Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
R. David Murray <rdmurray@bitdance.com>
parents: 52389
diff changeset
19 from 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')
c9da08d482c3 initscr() will exit if there's an error. Try to catch the obvious failure
Neal Norwitz <nnorwitz@gmail.com>
parents: 36197
diff changeset
21
52625
f84340886936 Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
R. David Murray <rdmurray@bitdance.com>
parents: 52389
diff changeset
22 # If either of these don't exist, skip the tests.
f84340886936 Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
R. David Murray <rdmurray@bitdance.com>
parents: 52389
diff changeset
23 curses = import_module('curses')
f84340886936 Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
R. David Murray <rdmurray@bitdance.com>
parents: 52389
diff changeset
24 curses.panel = import_module('curses.panel')
f84340886936 Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
R. David Murray <rdmurray@bitdance.com>
parents: 52389
diff changeset
25
58981
0340804ad713 Merged revisions 78281 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 56738
diff changeset
26
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
27 # 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
28 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
29 if not term or term == 'unknown':
52389
d4e7470bd660 Merged revisions 70554,70588-70589,70598,70605,70611-70621,70623-70624,70626-70627 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 47201
diff changeset
30 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
31
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36274
diff changeset
32 if sys.platform == "cygwin":
52389
d4e7470bd660 Merged revisions 70554,70588-70589,70598,70605,70611-70621,70623-70624,70626-70627 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 47201
diff changeset
33 raise unittest.SkipTest("cygwin's curses mostly just hangs")
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36274
diff changeset
34
20610
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
35 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
36 "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
37 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
38 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
39 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
40
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
41 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
42 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
43 (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
44 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
45
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
46 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 meth()
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
56
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('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('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 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
60 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
61
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.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
63 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
64 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
65 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
66 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
67 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
68 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
69
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(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
71 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
72 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
73 '+', '\\', '#', '/')
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
74 try:
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
75 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
76 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
77 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
78 pass
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
79 else:
43014
9834301a2fd3 Raise statement normalization in Lib/test/.
Collin Winter <collinw@gmail.com>
parents: 41554
diff changeset
80 raise RuntimeError("Expected win.border() to raise TypeError")
20610
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 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
83
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 = 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
85 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
86 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
87
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.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
89 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
90 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
91 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
92 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
93 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
94
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.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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104
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('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('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.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
108 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
109 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
110 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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 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
119 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
120 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
121
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.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
123 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
124 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
125 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
126
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
127 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
128 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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 stdscr.vline('a', 3, curses.A_STANDOUT)
41554
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
137 stdscr.chgat(5, 2, 3, curses.A_BLINK)
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
138 stdscr.chgat(3, curses.A_BOLD)
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
139 stdscr.chgat(5, 8, curses.A_UNDERLINE)
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
140 stdscr.chgat(curses.A_BLINK)
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
141 stdscr.refresh()
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
142
20610
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
143 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
144 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
145
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, 'resize'):
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.resize()
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
148 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
149 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
150
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
151
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
152 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
153 "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
154
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164 func()
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
165
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
166 # Functions that actually need arguments
32996
30025965324a This is more-or-less:
Michael W. Hudson <mwh@python.net>
parents: 31389
diff changeset
167 if curses.tigetstr("cnorm"):
30025965324a This is more-or-less:
Michael W. Hudson <mwh@python.net>
parents: 31389
diff changeset
168 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
169 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
170 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
171
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 = 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
173 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
174 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
175 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
176 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
177
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.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
179 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
180 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
181 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
182 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
183 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
184 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
185 curses.nl() ; curses.nl(1)
73331
38f4a251608f Issue #10570: curses.putp() is now expecting a byte string, instead of a
Victor Stinner <victor.stinner@haypocalc.com>
parents: 73311
diff changeset
186 curses.putp(b'abc')
20610
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.qiflush()
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.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
189 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
190 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
191 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
192 curses.tigetstr('cr')
73311
e41663970ca5 Issue #10570: curses.tigetstr() is now expecting a byte string, instead of a
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63793
diff changeset
193 curses.tparm(b'cr')
20610
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.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
195 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
196 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
197 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
198
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
199 # 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
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207
32996
30025965324a This is more-or-less:
Michael W. Hudson <mwh@python.net>
parents: 31389
diff changeset
208 if hasattr(curses, 'use_default_colors'):
30025965324a This is more-or-less:
Michael W. Hudson <mwh@python.net>
parents: 31389
diff changeset
209 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
210
20610
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
211 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
212 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
213
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
214 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
215 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
216
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
217 if hasattr(curses, 'getmouse'):
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36274
diff changeset
218 (availmask, oldmask) = curses.mousemask(curses.BUTTON1_PRESSED)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36274
diff changeset
219 # availmask indicates that mouse stuff not available.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36274
diff changeset
220 if availmask != 0:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36274
diff changeset
221 curses.mouseinterval(10)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36274
diff changeset
222 # just verify these don't cause errors
63793
9b802b6b4395 Issue #8433: Fix test_curses failure for platforms with recent versions of ncurses.
Mark Dickinson <dickinsm@gmail.com>
parents: 62178
diff changeset
223 curses.ungetmouse(0, 0, 0, 0, curses.BUTTON1_PRESSED)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36274
diff changeset
224 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
225
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
226 if hasattr(curses, 'is_term_resized'):
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
227 curses.is_term_resized(*stdscr.getmaxyx())
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
228 if hasattr(curses, 'resizeterm'):
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
229 curses.resizeterm(*stdscr.getmaxyx())
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
230 if hasattr(curses, 'resize_term'):
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
231 curses.resize_term(*stdscr.getmaxyx())
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
232
30233
c47f5ac8b06d Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents: 30140
diff changeset
233 def unit_tests():
c47f5ac8b06d Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents: 30140
diff changeset
234 from curses import ascii
c47f5ac8b06d Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents: 30140
diff changeset
235 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
236 (';', ';'), (' ', ' '),
30235
7f34652d7161 Add tests for meta- bit set
Andrew M. Kuchling <amk@amk.ca>
parents: 30233
diff changeset
237 ('\x7f', '^?'), ('\n', '^J'), ('\0', '^@'),
7f34652d7161 Add tests for meta- bit set
Andrew M. Kuchling <amk@amk.ca>
parents: 30233
diff changeset
238 # Meta-bit characters
7f34652d7161 Add tests for meta- bit set
Andrew M. Kuchling <amk@amk.ca>
parents: 30233
diff changeset
239 ('\x8a', '!^J'), ('\xc1', '!A'),
7f34652d7161 Add tests for meta- bit set
Andrew M. Kuchling <amk@amk.ca>
parents: 30233
diff changeset
240 ]:
30233
c47f5ac8b06d Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents: 30140
diff changeset
241 if ascii.unctrl(ch) != expected:
40775
4cdf21a0dbbc Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
242 print('curses.unctrl fails on character', repr(ch))
31389
aca1ce1b4b61 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 30235
diff changeset
243
30233
c47f5ac8b06d Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents: 30140
diff changeset
244
36251
8df194294c90 Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents: 36214
diff changeset
245 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
246 w = curses.newwin(10, 10)
8df194294c90 Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents: 36214
diff changeset
247 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
248 # 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
249 try:
8df194294c90 Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents: 36214
diff changeset
250 p.userptr()
43014
9834301a2fd3 Raise statement normalization in Lib/test/.
Collin Winter <collinw@gmail.com>
parents: 41554
diff changeset
251 raise RuntimeError('userptr should fail since not set')
36251
8df194294c90 Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents: 36214
diff changeset
252 except curses.panel.error:
8df194294c90 Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents: 36214
diff changeset
253 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
254
41554
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
255 def test_resize_term(stdscr):
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
256 if hasattr(curses, 'resizeterm'):
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
257 lines, cols = curses.LINES, curses.COLS
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
258 curses.resizeterm(lines - 1, cols + 1)
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
259
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
260 if curses.LINES != lines - 1 or curses.COLS != cols + 1:
43014
9834301a2fd3 Raise statement normalization in Lib/test/.
Collin Winter <collinw@gmail.com>
parents: 41554
diff changeset
261 raise RuntimeError("Expected resizeterm to update LINES and COLS")
41554
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
262
56384
6b23b0eba405 Merged revisions 75248 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 55609
diff changeset
263 def test_issue6243(stdscr):
6b23b0eba405 Merged revisions 75248 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 55609
diff changeset
264 curses.ungetch(1025)
6b23b0eba405 Merged revisions 75248 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 55609
diff changeset
265 stdscr.getkey()
6b23b0eba405 Merged revisions 75248 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 55609
diff changeset
266
73311
e41663970ca5 Issue #10570: curses.tigetstr() is now expecting a byte string, instead of a
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63793
diff changeset
267 def test_issue10570():
e41663970ca5 Issue #10570: curses.tigetstr() is now expecting a byte string, instead of a
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63793
diff changeset
268 b = curses.tparm(curses.tigetstr("cup"), 5, 3)
e41663970ca5 Issue #10570: curses.tigetstr() is now expecting a byte string, instead of a
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63793
diff changeset
269 assert type(b) is bytes
73331
38f4a251608f Issue #10570: curses.putp() is now expecting a byte string, instead of a
Victor Stinner <victor.stinner@haypocalc.com>
parents: 73311
diff changeset
270 curses.putp(b)
73311
e41663970ca5 Issue #10570: curses.tigetstr() is now expecting a byte string, instead of a
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63793
diff changeset
271
20610
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
272 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
273 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
274 try:
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
275 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
276 window_funcs(stdscr)
36251
8df194294c90 Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents: 36214
diff changeset
277 test_userptr_without_set(stdscr)
41554
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40775
diff changeset
278 test_resize_term(stdscr)
56384
6b23b0eba405 Merged revisions 75248 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 55609
diff changeset
279 test_issue6243(stdscr)
73311
e41663970ca5 Issue #10570: curses.tigetstr() is now expecting a byte string, instead of a
Victor Stinner <victor.stinner@haypocalc.com>
parents: 63793
diff changeset
280 test_issue10570()
20610
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
281 finally:
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
282 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
283
55609
9d40586a6afc Merged revisions 74126,74130-74131,74149,74155,74157,74180-74183,74398 via svnmerge from
Georg Brandl <georg@python.org>
parents: 54657
diff changeset
284 def test_main():
56738
8ac907015605 Merged revisions 75519 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 56384
diff changeset
285 if not sys.stdout.isatty():
8ac907015605 Merged revisions 75519 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 56384
diff changeset
286 raise unittest.SkipTest("sys.stdout is not a tty")
45534
7afef8f43e4a Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61064,61066-61080 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43014
diff changeset
287 # testing setupterm() inside initscr/endwin
7afef8f43e4a Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61064,61066-61080 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43014
diff changeset
288 # causes terminal breakage
55609
9d40586a6afc Merged revisions 74126,74130-74131,74149,74155,74157,74180-74183,74398 via svnmerge from
Georg Brandl <georg@python.org>
parents: 54657
diff changeset
289 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
290 try:
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
291 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
292 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
293 finally:
7dcc8a28133a Patch #473187: Add a test script that exercises most of the functions in
Andrew M. Kuchling <amk@amk.ca>
parents:
diff changeset
294 curses.endwin()
30233
c47f5ac8b06d Add simple unit test for ascii.unctrl() function
Andrew M. Kuchling <amk@amk.ca>
parents: 30140
diff changeset
295 unit_tests()
55609
9d40586a6afc Merged revisions 74126,74130-74131,74149,74155,74157,74180-74183,74398 via svnmerge from
Georg Brandl <georg@python.org>
parents: 54657
diff changeset
296
9d40586a6afc Merged revisions 74126,74130-74131,74149,74155,74157,74180-74183,74398 via svnmerge from
Georg Brandl <georg@python.org>
parents: 54657
diff changeset
297 if __name__ == '__main__':
9d40586a6afc Merged revisions 74126,74130-74131,74149,74155,74157,74180-74183,74398 via svnmerge from
Georg Brandl <georg@python.org>
parents: 54657
diff changeset
298 curses.wrapper(main)
9d40586a6afc Merged revisions 74126,74130-74131,74149,74155,74157,74180-74183,74398 via svnmerge from
Georg Brandl <georg@python.org>
parents: 54657
diff changeset
299 unit_tests()