mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 20:35:00 +00:00
style: Format Python code with black
This commit is contained in:
parent
a480b90217
commit
b29a6e8fa4
1 changed files with 16 additions and 14 deletions
|
@ -1,26 +1,27 @@
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from aider.coders import Coder
|
from aider.coders import Coder
|
||||||
from aider.models import Model
|
|
||||||
from aider.io import InputOutput
|
from aider.io import InputOutput
|
||||||
|
from aider.models import Model
|
||||||
|
|
||||||
|
|
||||||
class TestScriptingAPI(unittest.TestCase):
|
class TestScriptingAPI(unittest.TestCase):
|
||||||
|
@patch("aider.coders.Coder.create")
|
||||||
@patch('aider.coders.Coder.create')
|
@patch("aider.models.Model")
|
||||||
@patch('aider.models.Model')
|
|
||||||
def test_basic_scripting(self, mock_model, mock_coder_create):
|
def test_basic_scripting(self, mock_model, mock_coder_create):
|
||||||
# Setup
|
# Setup
|
||||||
mock_coder = MagicMock()
|
mock_coder = MagicMock()
|
||||||
mock_coder_create.return_value = mock_coder
|
mock_coder_create.return_value = mock_coder
|
||||||
|
|
||||||
# Test script
|
# Test script
|
||||||
fnames = ["greeting.py"]
|
fnames = ["greeting.py"]
|
||||||
model = Model("gpt-4-turbo")
|
model = Model("gpt-4-turbo")
|
||||||
coder = Coder.create(main_model=model, fnames=fnames)
|
coder = Coder.create(main_model=model, fnames=fnames)
|
||||||
|
|
||||||
coder.run("make a script that prints hello world")
|
coder.run("make a script that prints hello world")
|
||||||
coder.run("make it say goodbye")
|
coder.run("make it say goodbye")
|
||||||
|
|
||||||
# Assertions
|
# Assertions
|
||||||
mock_model.assert_called_once_with("gpt-4-turbo")
|
mock_model.assert_called_once_with("gpt-4-turbo")
|
||||||
mock_coder_create.assert_called_once_with(main_model=model, fnames=fnames)
|
mock_coder_create.assert_called_once_with(main_model=model, fnames=fnames)
|
||||||
|
@ -28,26 +29,27 @@ class TestScriptingAPI(unittest.TestCase):
|
||||||
mock_coder.run.assert_any_call("make a script that prints hello world")
|
mock_coder.run.assert_any_call("make a script that prints hello world")
|
||||||
mock_coder.run.assert_any_call("make it say goodbye")
|
mock_coder.run.assert_any_call("make it say goodbye")
|
||||||
|
|
||||||
@patch('aider.coders.Coder.create')
|
@patch("aider.coders.Coder.create")
|
||||||
@patch('aider.models.Model')
|
@patch("aider.models.Model")
|
||||||
def test_scripting_with_io(self, mock_model, mock_coder_create):
|
def test_scripting_with_io(self, mock_model, mock_coder_create):
|
||||||
# Setup
|
# Setup
|
||||||
mock_coder = MagicMock()
|
mock_coder = MagicMock()
|
||||||
mock_coder_create.return_value = mock_coder
|
mock_coder_create.return_value = mock_coder
|
||||||
|
|
||||||
# Test script
|
# Test script
|
||||||
fnames = ["greeting.py"]
|
fnames = ["greeting.py"]
|
||||||
model = Model("gpt-4-turbo")
|
model = Model("gpt-4-turbo")
|
||||||
io = InputOutput(yes=True)
|
io = InputOutput(yes=True)
|
||||||
coder = Coder.create(main_model=model, fnames=fnames, io=io)
|
coder = Coder.create(main_model=model, fnames=fnames, io=io)
|
||||||
|
|
||||||
coder.run("add a new function")
|
coder.run("add a new function")
|
||||||
|
|
||||||
# Assertions
|
# Assertions
|
||||||
mock_model.assert_called_once_with("gpt-4-turbo")
|
mock_model.assert_called_once_with("gpt-4-turbo")
|
||||||
mock_coder_create.assert_called_once_with(main_model=model, fnames=fnames, io=io)
|
mock_coder_create.assert_called_once_with(main_model=model, fnames=fnames, io=io)
|
||||||
mock_coder.run.assert_called_once_with("add a new function")
|
mock_coder.run.assert_called_once_with("add a new function")
|
||||||
self.assertTrue(io.yes) # Check that 'yes' is set to True
|
self.assertTrue(io.yes) # Check that 'yes' is set to True
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue