From 57020a2d5e2a12aea4c46276843c3eb2e7ae24d4 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sun, 11 May 2025 08:16:08 -0700 Subject: [PATCH] test: Assert specific stderr messages for invalid edit format --- tests/basic/test_main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/basic/test_main.py b/tests/basic/test_main.py index 40119669e..1fe387ccf 100644 --- a/tests/basic/test_main.py +++ b/tests/basic/test_main.py @@ -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():