test: Assert specific stderr messages for invalid edit format

This commit is contained in:
Paul Gauthier (aider) 2025-05-11 08:16:08 -07:00
parent 6b9045a2a2
commit 57020a2d5e

View file

@ -950,7 +950,7 @@ class TestMain(TestCase):
def test_invalid_edit_format(self):
with GitTemporaryDirectory():
# 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) as mock_stderr:
with self.assertRaises(SystemExit) as cm:
_ = main(
["--edit-format", "not-a-real-format", "--exit", "--yes"],
@ -959,6 +959,9 @@ class TestMain(TestCase):
)
# argparse.ArgumentParser.exit() is called with status 2 for invalid choice
self.assertEqual(cm.exception.code, 2)
stderr_output = mock_stderr.getvalue()
self.assertIn("invalid choice", stderr_output)
self.assertIn("not-a-real-format", stderr_output)
def test_default_model_selection(self):
with GitTemporaryDirectory():