Working on adding pager.
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user