ยปCore Development>Code coverage>Lib/test/curses_tests.py

Python code coverage for Lib/test/curses_tests.py

#countcontent
1n/a#!/usr/bin/env python3
2n/a#
3n/a# $Id: ncurses.py 36559 2004-07-18 05:56:09Z tim_one $
4n/a#
5n/a# Interactive test suite for the curses module.
6n/a# This script displays various things and the user should verify whether
7n/a# they display correctly.
8n/a#
9n/a
10n/aimport curses
11n/afrom curses import textpad
12n/a
13n/adef test_textpad(stdscr, insert_mode=False):
14n/a ncols, nlines = 8, 3
15n/a uly, ulx = 3, 2
16n/a if insert_mode:
17n/a mode = 'insert mode'
18n/a else:
19n/a mode = 'overwrite mode'
20n/a
21n/a stdscr.addstr(uly-3, ulx, "Use Ctrl-G to end editing (%s)." % mode)
22n/a stdscr.addstr(uly-2, ulx, "Be sure to try typing in the lower-right corner.")
23n/a win = curses.newwin(nlines, ncols, uly, ulx)
24n/a textpad.rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols)
25n/a stdscr.refresh()
26n/a
27n/a box = textpad.Textbox(win, insert_mode)
28n/a contents = box.edit()
29n/a stdscr.addstr(uly+ncols+2, 0, "Text entered in the box\n")
30n/a stdscr.addstr(repr(contents))
31n/a stdscr.addstr('\n')
32n/a stdscr.addstr('Press any key')
33n/a stdscr.getch()
34n/a
35n/a for i in range(3):
36n/a stdscr.move(uly+ncols+2 + i, 0)
37n/a stdscr.clrtoeol()
38n/a
39n/adef main(stdscr):
40n/a stdscr.clear()
41n/a test_textpad(stdscr, False)
42n/a test_textpad(stdscr, True)
43n/a
44n/a
45n/aif __name__ == '__main__':
46n/a curses.wrapper(main)