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():