mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 00:05:01 +00:00
test: add tests for multiline mode restoration after prompt interrupts
This commit is contained in:
parent
2e1e26fdb9
commit
9b80b693c1
1 changed files with 40 additions and 0 deletions
|
@ -353,6 +353,46 @@ class TestInputOutputMultilineMode(unittest.TestCase):
|
|||
# The invalid Unicode should be replaced with '?'
|
||||
self.assertEqual(converted_message, "Hello ?World")
|
||||
|
||||
def test_multiline_mode_restored_after_interrupt(self):
|
||||
"""Test that multiline mode is restored after KeyboardInterrupt"""
|
||||
io = InputOutput(fancy_input=True)
|
||||
io.prompt_session = MagicMock()
|
||||
|
||||
# Start in multiline mode
|
||||
io.multiline_mode = True
|
||||
|
||||
# Mock prompt() to raise KeyboardInterrupt
|
||||
io.prompt_session.prompt.side_effect = KeyboardInterrupt
|
||||
|
||||
# Test confirm_ask()
|
||||
with self.assertRaises(KeyboardInterrupt):
|
||||
io.confirm_ask("Test question?")
|
||||
self.assertTrue(io.multiline_mode) # Should be restored
|
||||
|
||||
# Test prompt_ask()
|
||||
with self.assertRaises(KeyboardInterrupt):
|
||||
io.prompt_ask("Test prompt?")
|
||||
self.assertTrue(io.multiline_mode) # Should be restored
|
||||
|
||||
def test_multiline_mode_restored_after_normal_exit(self):
|
||||
"""Test that multiline mode is restored after normal exit"""
|
||||
io = InputOutput(fancy_input=True)
|
||||
io.prompt_session = MagicMock()
|
||||
|
||||
# Start in multiline mode
|
||||
io.multiline_mode = True
|
||||
|
||||
# Mock prompt() to return normally
|
||||
io.prompt_session.prompt.return_value = "y"
|
||||
|
||||
# Test confirm_ask()
|
||||
io.confirm_ask("Test question?")
|
||||
self.assertTrue(io.multiline_mode) # Should be restored
|
||||
|
||||
# Test prompt_ask()
|
||||
io.prompt_ask("Test prompt?")
|
||||
self.assertTrue(io.multiline_mode) # Should be restored
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue