Permalink
Browse files

Fix #91: Update feed_key to feed and process_keys

feed_key was separated to feed and process_keys in prompt-toolkit 1.0.1.
  • Loading branch information...
1 parent d184e01 commit 18a3a70997c492a8213624a4bf9ce8f9572fe2e1 @donnemartin committed Jun 16, 2016
Showing with 13 additions and 8 deletions.
  1. +2 −1 saws/saws.py
  2. +10 −6 tests/test_keys.py
  3. +1 −1 tests/test_saws.py
View
@@ -366,7 +366,8 @@ def _handle_keyboard_interrupt(self, e, platform):
else:
# Clear the renderer and send a carriage return
self.aws_cli.renderer.clear()
- self.aws_cli.input_processor.feed_key(KeyPress(Keys.ControlM, ''))
+ self.aws_cli.input_processor.feed(KeyPress(Keys.ControlM, u''))
+ self.aws_cli.input_processor.process_keys()
def _process_command(self, text):
"""Processes the input command, called by the cli event loop
View
@@ -31,31 +31,35 @@ def setUp(self):
self.DOCS_HOME_URL = \
'http://docs.aws.amazon.com/cli/latest/reference/index.html'
+ def feed_key(self, key):
+ self.processor.feed(KeyPress(key, u''))
+ self.processor.process_keys()
+
def test_F2(self):
orig_color = self.saws.get_color()
- self.processor.feed_key(KeyPress(Keys.F2, ''))
+ self.feed_key(Keys.F2)
assert orig_color != self.saws.get_color()
def test_F3(self):
orig_fuzzy = self.saws.get_fuzzy_match()
- self.processor.feed_key(KeyPress(Keys.F3, ''))
+ self.feed_key(Keys.F3)
assert orig_fuzzy != self.saws.get_fuzzy_match()
def test_F4(self):
orig_shortcut = self.saws.get_shortcut_match()
- self.processor.feed_key(KeyPress(Keys.F4, ''))
+ self.feed_key(Keys.F4)
assert orig_shortcut != self.saws.get_shortcut_match()
@mock.patch('saws.saws.webbrowser')
def test_F9(self, mock_webbrowser):
- self.processor.feed_key(KeyPress(Keys.F9, ''))
+ self.feed_key(Keys.F9)
mock_webbrowser.open.assert_called_with(self.DOCS_HOME_URL)
def test_F10(self):
with self.assertRaises(EOFError):
- self.processor.feed_key(KeyPress(Keys.F10, ''))
+ self.feed_key(Keys.F10)
@mock.patch('saws.resources.print')
def test_f5(self, mock_print):
- self.processor.feed_key(KeyPress(Keys.F5, ''))
+ self.feed_key(Keys.F5)
mock_print.assert_called_with('Done refreshing')
View
@@ -143,7 +143,7 @@ def test_process_command(self, mock_subprocess):
def test_handle_keyboard_interrupt(self):
e = KeyboardInterrupt('')
- # TODO: Mock calls to renderer.clear and input_processor.feed_key
+ # TODO: Mock calls to renderer.clear and input_processor.feed
self.saws._handle_keyboard_interrupt(e, platform='Darwin')
with self.assertRaises(KeyboardInterrupt):
self.saws._handle_keyboard_interrupt(e, platform='Windows')

0 comments on commit 18a3a70

Please sign in to comment.