mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 05:45:00 +00:00
working test
This commit is contained in:
parent
b4f78547bc
commit
d00e7c39d1
1 changed files with 8 additions and 4 deletions
|
@ -1,11 +1,12 @@
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from aider import models
|
||||||
from aider.coders.wholefile_coder import WholeFileCoder
|
from aider.coders.wholefile_coder import WholeFileCoder
|
||||||
from aider.io import InputOutput
|
from aider.io import InputOutput
|
||||||
|
|
||||||
|
|
||||||
class TestWholeFileCoder(unittest.TestCase):
|
class TestWholeFileCoder(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.original_cwd = os.getcwd()
|
self.original_cwd = os.getcwd()
|
||||||
|
@ -15,14 +16,16 @@ class TestWholeFileCoder(unittest.TestCase):
|
||||||
|
|
||||||
def test_update_files(self):
|
def test_update_files(self):
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
|
os.chdir(temp_dir)
|
||||||
|
|
||||||
# Create a sample file in the temporary directory
|
# Create a sample file in the temporary directory
|
||||||
sample_file = os.path.join(temp_dir, "sample.txt")
|
sample_file = "sample.txt"
|
||||||
with open(sample_file, "w") as f:
|
with open(sample_file, "w") as f:
|
||||||
f.write("Original content\n")
|
f.write("Original content\n")
|
||||||
|
|
||||||
# Initialize WholeFileCoder with the temporary directory
|
# Initialize WholeFileCoder with the temporary directory
|
||||||
io = InputOutput(yes=yes)
|
io = InputOutput(yes=True)
|
||||||
coder = WholeFileCoder(root=temp_dir, io=io)
|
coder = WholeFileCoder(main_model=models.GPT35, io=io, fnames=[sample_file])
|
||||||
|
|
||||||
# Set the partial response content with the updated content
|
# Set the partial response content with the updated content
|
||||||
coder.partial_response_content = f"{sample_file}\n```\nUpdated content\n```"
|
coder.partial_response_content = f"{sample_file}\n```\nUpdated content\n```"
|
||||||
|
@ -38,5 +41,6 @@ class TestWholeFileCoder(unittest.TestCase):
|
||||||
updated_content = f.read()
|
updated_content = f.read()
|
||||||
self.assertEqual(updated_content, "Updated content\n")
|
self.assertEqual(updated_content, "Updated content\n")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue