Skip to content

Commit 6b3cffe

Browse files
committed
Fixed integration tests for key bindings.
1 parent 940c6e8 commit 6b3cffe

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

awsshell/app.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ class AWSShell(object):
220220
221221
"""
222222

223-
def __init__(self, completer, model_completer, docs):
223+
def __init__(self, completer, model_completer, docs,
224+
input=None, output=None):
224225
self.completer = completer
225226
self.model_completer = model_completer
226227
self.history = InMemoryHistory()
@@ -233,6 +234,8 @@ def __init__(self, completer, model_completer, docs):
233234
self._dot_cmd = DotCommandHandler()
234235
self._env = os.environ.copy()
235236
self._profile = None
237+
self._input = input
238+
self._output = output
236239

237240
# These attrs come from the config file.
238241
self.config_obj = None
@@ -456,7 +459,8 @@ def create_cli_interface(self, display_completions_in_columns):
456459
app = self.create_application(self.completer,
457460
self.file_history,
458461
display_completions_in_columns)
459-
cli = CommandLineInterface(application=app, eventloop=loop)
462+
cli = CommandLineInterface(application=app, eventloop=loop,
463+
input=self._input, output=self._output)
460464
return cli
461465

462466
@property

tests/integration/test_keys.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
1313
import mock
14-
import sys
1514

15+
from prompt_toolkit.input import PipeInput
16+
from prompt_toolkit.output import DummyOutput
1617
from prompt_toolkit.key_binding.input_processor import KeyPress
1718
from prompt_toolkit.keys import Keys
18-
from prompt_toolkit.interface import CommandLineInterface
1919

2020
from tests.compat import unittest
2121
from awsshell.app import AWSShell, InputInterrupt
@@ -24,9 +24,15 @@
2424
class KeysTest(unittest.TestCase):
2525

2626
def setUp(self):
27-
self.aws_shell = AWSShell(None, mock.Mock(), mock.Mock())
27+
self.input = PipeInput()
28+
output = DummyOutput()
29+
self.aws_shell = AWSShell(None, mock.Mock(), mock.Mock(),
30+
input=self.input, output=output)
2831
self.processor = self.aws_shell.cli.input_processor
2932

33+
def tearDown(self):
34+
self.input.close()
35+
3036
def feed_key(self, key):
3137
self.processor.feed(KeyPress(key, u''))
3238
self.processor.process_keys()

0 commit comments

Comments
 (0)