mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
test: add test for Coder.create with OSError on new file
This commit is contained in:
parent
58120cb882
commit
4a3e8ba41d
1 changed files with 16 additions and 0 deletions
|
@ -846,6 +846,22 @@ This command will print 'Hello, World!' to the console."""
|
|||
# Check if handle_shell_commands was called with the correct argument
|
||||
coder.handle_shell_commands.assert_not_called()
|
||||
|
||||
def test_coder_create_with_new_file_oserror(self):
|
||||
with GitTemporaryDirectory():
|
||||
io = InputOutput(yes=True)
|
||||
new_file = "new_file.txt"
|
||||
|
||||
# Mock Path.touch() to raise OSError
|
||||
with patch('pathlib.Path.touch', side_effect=OSError("Permission denied")):
|
||||
# Create the coder with a new file
|
||||
coder = Coder.create(self.GPT35, "diff", io=io, fnames=[new_file])
|
||||
|
||||
# Check if the coder was created successfully
|
||||
self.assertIsInstance(coder, Coder)
|
||||
|
||||
# Check if the new file is not in abs_fnames
|
||||
self.assertNotIn(new_file, [os.path.basename(f) for f in coder.abs_fnames])
|
||||
|
||||
def test_show_exhausted_error(self):
|
||||
with GitTemporaryDirectory():
|
||||
io = InputOutput(yes=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue