summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2024-11-18 14:39:55 +0100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-11-18 15:15:44 +0100
commite035db1bc3bbeb4282a177ad106add3b07d97b09 (patch)
tree2a846db16cb49783b4ca2d533a183510ddcd0bce /tests
parent3434fab758c5a293c8f376bb5990af6acbf89e32 (diff)
Fixed #35882 -- Made migration questioner loop on all errors.
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_questioner.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/migrations/test_questioner.py b/tests/migrations/test_questioner.py
index a212fbf65f..ec1013923b 100644
--- a/tests/migrations/test_questioner.py
+++ b/tests/migrations/test_questioner.py
@@ -61,10 +61,27 @@ class QuestionerHelperMethodsTests(SimpleTestCase):
)
@mock.patch("builtins.input", side_effect=["bad code", "exit"])
- def test_questioner_no_default_bad_user_entry_code(self, mock_input):
+ def test_questioner_no_default_syntax_error(self, mock_input):
with self.assertRaises(SystemExit):
self.questioner._ask_default()
- self.assertIn("Invalid input: ", self.prompt.getvalue())
+ self.assertIn("SyntaxError: invalid syntax", self.prompt.getvalue())
+
+ @mock.patch("builtins.input", side_effect=["datetim", "exit"])
+ def test_questioner_no_default_name_error(self, mock_input):
+ with self.assertRaises(SystemExit):
+ self.questioner._ask_default()
+ self.assertIn(
+ "NameError: name 'datetim' is not defined", self.prompt.getvalue()
+ )
+
+ @mock.patch("builtins.input", side_effect=["datetime.dat", "exit"])
+ def test_questioner_no_default_attribute_error(self, mock_input):
+ with self.assertRaises(SystemExit):
+ self.questioner._ask_default()
+ self.assertIn(
+ "AttributeError: module 'datetime' has no attribute 'dat'",
+ self.prompt.getvalue(),
+ )
@mock.patch("builtins.input", side_effect=[KeyboardInterrupt()])
def test_questioner_no_default_keyboard_interrupt(self, mock_input):