From 3434fab758c5a293c8f376bb5990af6acbf89e32 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 18 Nov 2024 14:41:24 +0100 Subject: [PATCH] Refs #35882 -- Added test for migration questioner KeyboardInterrupt. --- tests/migrations/test_questioner.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/migrations/test_questioner.py b/tests/migrations/test_questioner.py index c1aebcb224..a212fbf65f 100644 --- a/tests/migrations/test_questioner.py +++ b/tests/migrations/test_questioner.py @@ -66,6 +66,11 @@ class QuestionerHelperMethodsTests(SimpleTestCase): self.questioner._ask_default() self.assertIn("Invalid input: ", self.prompt.getvalue()) + @mock.patch("builtins.input", side_effect=[KeyboardInterrupt()]) + def test_questioner_no_default_keyboard_interrupt(self, mock_input): + with self.assertRaises(KeyboardInterrupt): + self.questioner._ask_default() + @mock.patch("builtins.input", side_effect=["", "n"]) def test_questioner_no_default_no_user_entry_boolean(self, mock_input): value = self.questioner._boolean_input("Proceed?")