Working on adding pager.

This commit is contained in:
Michael Lazar
2016-03-03 18:28:14 -08:00
parent 201ef8e6df
commit ffbd6c1dfd
5 changed files with 83 additions and 6 deletions

View File

@@ -308,4 +308,26 @@ def test_open_browser(terminal):
terminal.open_browser(url)
open_new_tab.assert_called_with(url)
assert curses.endwin.called
assert curses.doupdate.called
assert curses.doupdate.called
def test_open_pager(terminal, stdscr):
data = "Hello World!"
def side_effect(*_, stdin=None):
assert stdin is not None
raise OSError
with mock.patch('subprocess.Popen', autospec=True) as Popen, \
mock.patch.dict('os.environ', {'PAGER': 'fake'}):
terminal.open_pager(data)
assert Popen.called
assert not stdscr.addstr.called
# Raise an OS error
Popen.side_effect = side_effect
terminal.open_pager(data)
message = 'Could not open pager fake'.encode('ascii')
assert stdscr.addstr.called_with(0, 0, message)