mirror of
https://github.com/Aider-AI/aider
synced 2026-04-26 01:25:17 +02:00
test: add UnknownEditFormat exception tests
This commit is contained in:
@@ -879,6 +879,27 @@ This command will print 'Hello, World!' to the console."""
|
||||
self.assertEqual(result, [])
|
||||
coder.commands.scraper.scrape.assert_not_called()
|
||||
|
||||
def test_unknown_edit_format_exception(self):
|
||||
# Test the exception message format
|
||||
invalid_format = "invalid_format"
|
||||
valid_formats = ["diff", "whole", "map"]
|
||||
exc = UnknownEditFormat(invalid_format, valid_formats)
|
||||
expected_msg = f"Unknown edit format {invalid_format}. Valid formats are: {', '.join(valid_formats)}"
|
||||
self.assertEqual(str(exc), expected_msg)
|
||||
|
||||
def test_unknown_edit_format_creation(self):
|
||||
# Test that creating a Coder with invalid edit format raises the exception
|
||||
io = InputOutput(yes=True)
|
||||
invalid_format = "invalid_format"
|
||||
|
||||
with self.assertRaises(UnknownEditFormat) as cm:
|
||||
Coder.create(self.GPT35, invalid_format, io=io)
|
||||
|
||||
exc = cm.exception
|
||||
self.assertEqual(exc.edit_format, invalid_format)
|
||||
self.assertIsInstance(exc.valid_formats, list)
|
||||
self.assertTrue(len(exc.valid_formats) > 0)
|
||||
|
||||
def test_coder_create_with_new_file_oserror(self):
|
||||
with GitTemporaryDirectory():
|
||||
io = InputOutput(yes=True)
|
||||
|
||||
Reference in New Issue
Block a user