Fixed prompt sometimes not clearing.

This commit is contained in:
Michael Lazar
2015-12-08 00:28:55 -08:00
parent 8820ecdafe
commit 9d2a6af826
2 changed files with 28 additions and 12 deletions

View File

@@ -218,7 +218,7 @@ def test_prompt_input(terminal, stdscr, ascii):
assert isinstance(terminal.prompt_input('hi'), six.text_type)
attr = Color.CYAN | curses.A_BOLD
stdscr.addstr.assert_called_with(39, 0, 'hi'.encode('ascii'), attr)
stdscr.subwin.addstr.assert_called_with(0, 0, 'hi'.encode('ascii'), attr)
assert window.nlines == 1
assert window.ncols == 78
@@ -236,25 +236,26 @@ def test_prompt_y_or_n(terminal, stdscr):
stdscr.getch.side_effect = [ord('y'), ord('N'), terminal.ESCAPE, ord('a')]
attr = Color.CYAN | curses.A_BOLD
text = 'hi'.encode('ascii')
# Press 'y'
assert terminal.prompt_y_or_n('hi')
stdscr.addstr.assert_called_with(39, 0, 'hi'.encode('ascii'), attr)
stdscr.subwin.addstr.assert_called_with(0, 0, text, attr)
assert not curses.flash.called
# Press 'N'
assert not terminal.prompt_y_or_n('hi')
stdscr.addstr.assert_called_with(39, 0, 'hi'.encode('ascii'), attr)
stdscr.subwin.addstr.assert_called_with(0, 0, text, attr)
assert not curses.flash.called
# Press Esc
assert not terminal.prompt_y_or_n('hi')
stdscr.addstr.assert_called_with(39, 0, 'hi'.encode('ascii'), attr)
stdscr.subwin.addstr.assert_called_with(0, 0, text, attr)
assert not curses.flash.called
# Press an invalid key
assert not terminal.prompt_y_or_n('hi')
stdscr.addstr.assert_called_with(39, 0, 'hi'.encode('ascii'), attr)
stdscr.subwin.addstr.assert_called_with(0, 0, text, attr)
assert curses.flash.called