test: Fix invalid edit format test assertion

This commit is contained in:
Paul Gauthier (aider) 2025-05-11 08:15:03 -07:00
parent b79052501d
commit 5f24a0013a

View file

@ -949,19 +949,16 @@ 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: # Suppress stderr for this test as argparse prints an error message
# Suppress stderr for this test as argparse prints an error message with patch("sys.stderr", new_callable=StringIO):
with patch("sys.stderr", new_callable=StringIO): with self.assertRaises(SystemExit) as cm:
result = main( result = 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(),
) )
# main() should return 1 when argparse itself fails due to an invalid choice # argparse.ArgumentParser.exit() is called with status 2 for invalid choice
# (argparse exits with 2, which main converts to 1) self.assertEqual(cm.exception.code, 2)
self.assertEqual(result, 1)
# offer_url not called: argparse handles error before aider's custom check
mock_offer_url.assert_not_called()
def test_default_model_selection(self): def test_default_model_selection(self):
with GitTemporaryDirectory(): with GitTemporaryDirectory():