refactor: update env format test to check return value instead of SystemExit

This commit is contained in:
Paul Gauthier (aider) 2024-12-07 08:09:56 -08:00
parent 054e0820b7
commit ba14ab96da
2 changed files with 3 additions and 3 deletions

View file

@ -535,6 +535,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
except ValueError:
io.tool_error(f"Invalid --set-env format: {env_setting}")
io.tool_output("Format should be: ENV_VAR_NAME=value")
analytics.event("exit", reason="Invalid env var format")
return 1
analytics = Analytics(logfile=args.analytics_log, permanently_disable=args.analytics_disable)

View file

@ -703,9 +703,8 @@ class TestMain(TestCase):
def test_set_env_invalid_format(self):
# Test invalid format handling
with GitTemporaryDirectory():
with self.assertRaises(SystemExit) as cm:
main(["--set-env", "INVALID_FORMAT", "--exit", "--yes"])
self.assertEqual(cm.exception.code, 1)
result = main(["--set-env", "INVALID_FORMAT", "--exit", "--yes"])
self.assertEqual(result, 1)
def test_invalid_edit_format(self):
with GitTemporaryDirectory():