mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
fix: Correct test for invalid --edit-format argument
This commit is contained in:
parent
c055602c6f
commit
a53ab7d937
1 changed files with 12 additions and 9 deletions
|
@ -950,15 +950,18 @@ 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:
|
with patch("aider.io.InputOutput.offer_url") as mock_offer_url:
|
||||||
|
# Suppress stderr for this test as argparse prints an error message
|
||||||
|
with patch('sys.stderr', new_callable=StringIO):
|
||||||
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(),
|
||||||
)
|
)
|
||||||
self.assertEqual(result, 1) # main() should return 1 on error
|
# main() should return 1 when argparse itself fails due to an invalid choice
|
||||||
mock_offer_url.assert_called_once()
|
# (argparse exits with 2, which main converts to 1)
|
||||||
args, _ = mock_offer_url.call_args
|
self.assertEqual(result, 1)
|
||||||
self.assertEqual(args[0], "https://aider.chat/docs/more/edit-formats.html")
|
# offer_url is not called because argparse handles the 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():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue