Back to index

python3.2  3.2.2
Functions | Variables
test.test_curses Namespace Reference

Functions

def window_funcs
def module_funcs
def unit_tests
def test_userptr_without_set
def test_resize_term
def test_issue6243
def main
def test_main

Variables

tuple curses = import_module('curses')
tuple term = os.environ.get('TERM')

Function Documentation

def test.test_curses.main (   stdscr)

Definition at line 267 of file test_curses.py.

00267 
00268 def main(stdscr):
00269     curses.savetty()
00270     try:
00271         module_funcs(stdscr)
00272         window_funcs(stdscr)
00273         test_userptr_without_set(stdscr)
00274         test_resize_term(stdscr)
00275         test_issue6243(stdscr)
00276     finally:
00277         curses.resetty()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 152 of file test_curses.py.

00152 
00153 def module_funcs(stdscr):
00154     "Test module-level functions"
00155 
00156     for func in [curses.baudrate, curses.beep, curses.can_change_color,
00157                  curses.cbreak, curses.def_prog_mode, curses.doupdate,
00158                  curses.filter, curses.flash, curses.flushinp,
00159                  curses.has_colors, curses.has_ic, curses.has_il,
00160                  curses.isendwin, curses.killchar, curses.longname,
00161                  curses.nocbreak, curses.noecho, curses.nonl,
00162                  curses.noqiflush, curses.noraw,
00163                  curses.reset_prog_mode, curses.termattrs,
00164                  curses.termname, curses.erasechar, curses.getsyx]:
00165         func()
00166 
00167     # Functions that actually need arguments
00168     if curses.tigetstr("cnorm"):
00169         curses.curs_set(1)
00170     curses.delay_output(1)
00171     curses.echo() ; curses.echo(1)
00172 
00173     f = tempfile.TemporaryFile()
00174     stdscr.putwin(f)
00175     f.seek(0)
00176     curses.getwin(f)
00177     f.close()
00178 
00179     curses.halfdelay(1)
00180     curses.intrflush(1)
00181     curses.meta(1)
00182     curses.napms(100)
00183     curses.newpad(50,50)
00184     win = curses.newwin(5,5)
00185     win = curses.newwin(5,5, 1,1)
00186     curses.nl() ; curses.nl(1)
00187     curses.putp('abc')
00188     curses.qiflush()
00189     curses.raw() ; curses.raw(1)
00190     curses.setsyx(5,5)
00191     curses.tigetflag('hc')
00192     curses.tigetnum('co')
00193     curses.tigetstr('cr')
00194     curses.tparm('cr')
00195     curses.typeahead(sys.__stdin__.fileno())
00196     curses.unctrl('a')
00197     curses.ungetch('a')
00198     curses.use_env(1)
00199 
00200     # Functions only available on a few platforms
00201     if curses.has_colors():
00202         curses.start_color()
00203         curses.init_pair(2, 1,1)
00204         curses.color_content(1)
00205         curses.color_pair(2)
00206         curses.pair_content(curses.COLOR_PAIRS - 1)
00207         curses.pair_number(0)
00208 
00209         if hasattr(curses, 'use_default_colors'):
00210             curses.use_default_colors()
00211 
00212     if hasattr(curses, 'keyname'):
00213         curses.keyname(13)
00214 
00215     if hasattr(curses, 'has_key'):
00216         curses.has_key(13)
00217 
00218     if hasattr(curses, 'getmouse'):
00219         (availmask, oldmask) = curses.mousemask(curses.BUTTON1_PRESSED)
00220         # availmask indicates that mouse stuff not available.
00221         if availmask != 0:
00222             curses.mouseinterval(10)
00223             # just verify these don't cause errors
00224             curses.ungetmouse(0, 0, 0, 0, curses.BUTTON1_PRESSED)
00225             m = curses.getmouse()
00226 
00227     if hasattr(curses, 'is_term_resized'):
00228         curses.is_term_resized(*stdscr.getmaxyx())
00229     if hasattr(curses, 'resizeterm'):
00230         curses.resizeterm(*stdscr.getmaxyx())
00231     if hasattr(curses, 'resize_term'):
00232         curses.resize_term(*stdscr.getmaxyx())

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 263 of file test_curses.py.

00263 
00264 def test_issue6243(stdscr):
00265     curses.ungetch(1025)
00266     stdscr.getkey()

Here is the caller graph for this function:

Definition at line 278 of file test_curses.py.

00278 
00279 def test_main():
00280     if not sys.stdout.isatty():
00281         raise unittest.SkipTest("sys.stdout is not a tty")
00282     # testing setupterm() inside initscr/endwin
00283     # causes terminal breakage
00284     curses.setupterm(fd=sys.stdout.fileno())
00285     try:
00286         stdscr = curses.initscr()
00287         main(stdscr)
00288     finally:
00289         curses.endwin()
00290     unit_tests()

Here is the call graph for this function:

Definition at line 255 of file test_curses.py.

00255 
00256 def test_resize_term(stdscr):
00257     if hasattr(curses, 'resizeterm'):
00258         lines, cols = curses.LINES, curses.COLS
00259         curses.resizeterm(lines - 1, cols + 1)
00260 
00261         if curses.LINES != lines - 1 or curses.COLS != cols + 1:
00262             raise RuntimeError("Expected resizeterm to update LINES and COLS")

Here is the caller graph for this function:

Definition at line 245 of file test_curses.py.

00245 
00246 def test_userptr_without_set(stdscr):
00247     w = curses.newwin(10, 10)
00248     p = curses.panel.new_panel(w)
00249     # try to access userptr() before calling set_userptr() -- segfaults
00250     try:
00251         p.userptr()
00252         raise RuntimeError('userptr should fail since not set')
00253     except curses.panel.error:
00254         pass

Here is the caller graph for this function:

Definition at line 233 of file test_curses.py.

00233 
00234 def unit_tests():
00235     from curses import ascii
00236     for ch, expected in [('a', 'a'), ('A', 'A'),
00237                          (';', ';'), (' ', ' '),
00238                          ('\x7f', '^?'), ('\n', '^J'), ('\0', '^@'),
00239                          # Meta-bit characters
00240                          ('\x8a', '!^J'), ('\xc1', '!A'),
00241                          ]:
00242         if ascii.unctrl(ch) != expected:
00243             print('curses.unctrl fails on character', repr(ch))
00244 

Here is the caller graph for this function:

Definition at line 35 of file test_curses.py.

00035 
00036 def window_funcs(stdscr):
00037     "Test the methods of windows"
00038     win = curses.newwin(10,10)
00039     win = curses.newwin(5,5, 5,5)
00040     win2 = curses.newwin(15,15, 5,5)
00041 
00042     for meth in [stdscr.addch, stdscr.addstr]:
00043         for args in [('a'), ('a', curses.A_BOLD),
00044                      (4,4, 'a'), (5,5, 'a', curses.A_BOLD)]:
00045             meth(*args)
00046 
00047     for meth in [stdscr.box, stdscr.clear, stdscr.clrtobot,
00048                  stdscr.clrtoeol, stdscr.cursyncup, stdscr.delch,
00049                  stdscr.deleteln, stdscr.erase, stdscr.getbegyx,
00050                  stdscr.getbkgd, stdscr.getkey, stdscr.getmaxyx,
00051                  stdscr.getparyx, stdscr.getyx, stdscr.inch,
00052                  stdscr.insertln, stdscr.instr, stdscr.is_wintouched,
00053                  win.noutrefresh, stdscr.redrawwin, stdscr.refresh,
00054                  stdscr.standout, stdscr.standend, stdscr.syncdown,
00055                  stdscr.syncup, stdscr.touchwin, stdscr.untouchwin]:
00056         meth()
00057 
00058     stdscr.addnstr('1234', 3)
00059     stdscr.addnstr('1234', 3, curses.A_BOLD)
00060     stdscr.addnstr(4,4, '1234', 3)
00061     stdscr.addnstr(5,5, '1234', 3, curses.A_BOLD)
00062 
00063     stdscr.attron(curses.A_BOLD)
00064     stdscr.attroff(curses.A_BOLD)
00065     stdscr.attrset(curses.A_BOLD)
00066     stdscr.bkgd(' ')
00067     stdscr.bkgd(' ', curses.A_REVERSE)
00068     stdscr.bkgdset(' ')
00069     stdscr.bkgdset(' ', curses.A_REVERSE)
00070 
00071     win.border(65, 66, 67, 68,
00072                69, 70, 71, 72)
00073     win.border('|', '!', '-', '_',
00074                '+', '\\', '#', '/')
00075     try:
00076         win.border(65, 66, 67, 68,
00077                    69, [], 71, 72)
00078     except TypeError:
00079         pass
00080     else:
00081         raise RuntimeError("Expected win.border() to raise TypeError")
00082 
00083     stdscr.clearok(1)
00084 
00085     win4 = stdscr.derwin(2,2)
00086     win4 = stdscr.derwin(1,1, 5,5)
00087     win4.mvderwin(9,9)
00088 
00089     stdscr.echochar('a')
00090     stdscr.echochar('a', curses.A_BOLD)
00091     stdscr.hline('-', 5)
00092     stdscr.hline('-', 5, curses.A_BOLD)
00093     stdscr.hline(1,1,'-', 5)
00094     stdscr.hline(1,1,'-', 5, curses.A_BOLD)
00095 
00096     stdscr.idcok(1)
00097     stdscr.idlok(1)
00098     stdscr.immedok(1)
00099     stdscr.insch('c')
00100     stdscr.insdelln(1)
00101     stdscr.insnstr('abc', 3)
00102     stdscr.insnstr('abc', 3, curses.A_BOLD)
00103     stdscr.insnstr(5, 5, 'abc', 3)
00104     stdscr.insnstr(5, 5, 'abc', 3, curses.A_BOLD)
00105 
00106     stdscr.insstr('def')
00107     stdscr.insstr('def', curses.A_BOLD)
00108     stdscr.insstr(5, 5, 'def')
00109     stdscr.insstr(5, 5, 'def', curses.A_BOLD)
00110     stdscr.is_linetouched(0)
00111     stdscr.keypad(1)
00112     stdscr.leaveok(1)
00113     stdscr.move(3,3)
00114     win.mvwin(2,2)
00115     stdscr.nodelay(1)
00116     stdscr.notimeout(1)
00117     win2.overlay(win)
00118     win2.overwrite(win)
00119     win2.overlay(win, 1, 2, 3, 3, 2, 1)
00120     win2.overwrite(win, 1, 2, 3, 3, 2, 1)
00121     stdscr.redrawln(1,2)
00122 
00123     stdscr.scrollok(1)
00124     stdscr.scroll()
00125     stdscr.scroll(2)
00126     stdscr.scroll(-3)
00127 
00128     stdscr.move(12, 2)
00129     stdscr.setscrreg(10,15)
00130     win3 = stdscr.subwin(10,10)
00131     win3 = stdscr.subwin(10,10, 5,5)
00132     stdscr.syncok(1)
00133     stdscr.timeout(5)
00134     stdscr.touchline(5,5)
00135     stdscr.touchline(5,5,0)
00136     stdscr.vline('a', 3)
00137     stdscr.vline('a', 3, curses.A_STANDOUT)
00138     stdscr.chgat(5, 2, 3, curses.A_BLINK)
00139     stdscr.chgat(3, curses.A_BOLD)
00140     stdscr.chgat(5, 8, curses.A_UNDERLINE)
00141     stdscr.chgat(curses.A_BLINK)
00142     stdscr.refresh()
00143 
00144     stdscr.vline(1,1, 'a', 3)
00145     stdscr.vline(1,1, 'a', 3, curses.A_STANDOUT)
00146 
00147     if hasattr(curses, 'resize'):
00148         stdscr.resize()
00149     if hasattr(curses, 'enclose'):
00150         stdscr.enclose()
00151 

Here is the caller graph for this function:


Variable Documentation

tuple test.test_curses.curses = import_module('curses')

Definition at line 23 of file test_curses.py.

tuple test.test_curses.term = os.environ.get('TERM')

Definition at line 28 of file test_curses.py.