mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 04:14:59 +00:00
test: add UnknownEditFormat exception tests
This commit is contained in:
parent
cd79f7f4b0
commit
e3efab7fbf
1 changed files with 21 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue