Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e752e20

Browse files
committed
Add simple unit test for ascii.unctrl() function
1 parent ff638ea commit e752e20

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Lib/test/test_curses.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ def module_funcs(stdscr):
194194
curses.mousemask(curses.BUTTON1_PRESSED)
195195
curses.mouseinterval(10)
196196

197+
def unit_tests():
198+
from curses import ascii
199+
for ch, expected in [('a', 'a'), ('A', 'A'),
200+
(';', ';'), (' ', ' '),
201+
('\x7f', '^?'), ('\n', '^J'), ('\0', '^@')]:
202+
if ascii.unctrl(ch) != expected:
203+
print 'curses.unctrl fails on character', repr(ch)
204+
205+
197206

198207
def main(stdscr):
199208
curses.savetty()
@@ -203,11 +212,15 @@ def main(stdscr):
203212
finally:
204213
curses.resetty()
205214

215+
206216
if __name__ == '__main__':
207217
curses.wrapper(main)
218+
unit_tests()
208219
else:
209220
try:
210221
stdscr = curses.initscr()
211222
main(stdscr)
212223
finally:
213224
curses.endwin()
225+
226+
unit_tests()

0 commit comments

Comments
 (0)