test: update invalid edit format test to check return code instead of SystemExit

This commit is contained in:
Paul Gauthier (aider) 2024-11-26 07:07:11 -08:00
parent 743f0f5540
commit b70e0bd1f6

View file

@ -670,12 +670,12 @@ class TestMain(TestCase):
def test_invalid_edit_format(self): def test_invalid_edit_format(self):
with GitTemporaryDirectory(): with GitTemporaryDirectory():
with patch("aider.io.InputOutput.offer_url") as mock_offer_url: with patch("aider.io.InputOutput.offer_url") as mock_offer_url:
with self.assertRaises(SystemExit): result = main(
main( ["--edit-format", "not-a-real-format", "--exit", "--yes"],
["--edit-format", "not-a-real-format", "--exit", "--yes"], input=DummyInput(),
input=DummyInput(), output=DummyOutput(),
output=DummyOutput(), )
) self.assertEqual(result, 1) # main() should return 1 on error
mock_offer_url.assert_called_once() mock_offer_url.assert_called_once()
args, _ = mock_offer_url.call_args args, _ = mock_offer_url.call_args
self.assertEqual(args[0], "https://aider.chat/docs/edit-formats.html") self.assertEqual(args[0], "https://aider.chat/docs/edit-formats.html")