mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Add simple unit test for ascii.unctrl() function
This commit is contained in:
parent
ff638ea6db
commit
e752e20605
1 changed files with 13 additions and 0 deletions
|
|
@ -194,6 +194,15 @@ def module_funcs(stdscr):
|
|||
curses.mousemask(curses.BUTTON1_PRESSED)
|
||||
curses.mouseinterval(10)
|
||||
|
||||
def unit_tests():
|
||||
from curses import ascii
|
||||
for ch, expected in [('a', 'a'), ('A', 'A'),
|
||||
(';', ';'), (' ', ' '),
|
||||
('\x7f', '^?'), ('\n', '^J'), ('\0', '^@')]:
|
||||
if ascii.unctrl(ch) != expected:
|
||||
print 'curses.unctrl fails on character', repr(ch)
|
||||
|
||||
|
||||
|
||||
def main(stdscr):
|
||||
curses.savetty()
|
||||
|
|
@ -203,11 +212,15 @@ def main(stdscr):
|
|||
finally:
|
||||
curses.resetty()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
curses.wrapper(main)
|
||||
unit_tests()
|
||||
else:
|
||||
try:
|
||||
stdscr = curses.initscr()
|
||||
main(stdscr)
|
||||
finally:
|
||||
curses.endwin()
|
||||
|
||||
unit_tests()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue