Skip to content

Commit

Permalink
Merge 238991c into 93244a8
Browse files Browse the repository at this point in the history
  • Loading branch information
AuHau committed Sep 20, 2018
2 parents 93244a8 + 238991c commit 1f130cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions inquirer/render/console/_confirm.py
Expand Up @@ -15,6 +15,9 @@ def get_header(self):
c=confirm))

def process_input(self, pressed):
if pressed == key.CTRL_C:
raise KeyboardInterrupt()

if pressed.lower() == key.ENTER:
raise errors.EndOfInput(self.question.default)

Expand Down
11 changes: 11 additions & 0 deletions tests/integration/console_render/test_confirm.py
Expand Up @@ -129,3 +129,14 @@ def test_invalid_answer(self):

self.assertNotInStdout('Z')
self.assertTrue(result)

def test_ctrl_c_breaks_execution(self):
stdin = helper.event_factory(key.CTRL_C)
message = 'Foo message'
variable = 'Bar variable'

question = questions.Confirm(variable, message)

sut = ConsoleRender(event_generator=stdin)
with self.assertRaises(KeyboardInterrupt):
sut.render(question)

0 comments on commit 1f130cf

Please sign in to comment.