Skip to content

Commit

Permalink
refactor: Replace GitTemporaryDirectory with ChdirTemporaryDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-gauthier committed Nov 5, 2024
1 parent 9073084 commit 97051b9
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/basic/test_editblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from aider.dump import dump # noqa: F401
from aider.io import InputOutput
from aider.models import Model
from aider.utils import GitTemporaryDirectory
from aider.utils import ChdirTemporaryDirectory


class TestUtils(unittest.TestCase):
Expand Down Expand Up @@ -344,7 +344,7 @@ def test_replace_part_with_missing_leading_whitespace_including_blank_line(self)

def test_create_new_file_with_other_file_in_chat(self):
# https://github.com/Aider-AI/aider/issues/2258
with GitTemporaryDirectory():
with ChdirTemporaryDirectory():
# Create a few temporary files
file1 = "file.txt"

Expand All @@ -354,7 +354,9 @@ def test_create_new_file_with_other_file_in_chat(self):
files = [file1]

# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder.create(self.GPT35, "diff", io=InputOutput(yes=True), fnames=files)
coder = Coder.create(
self.GPT35, "diff", use_git=False, io=InputOutput(yes=True), fnames=files
)

def mock_send(*args, **kwargs):
coder.partial_response_content = f"""
Expand All @@ -372,11 +374,7 @@ def mock_send(*args, **kwargs):

coder.send = mock_send

def mock_sswr(*args, **kwargs):
return "noop"

with patch("aider.sendchat.simple_send_with_retries", mock_sswr):
coder.run(with_message="hi")
coder.run(with_message="hi")

content = Path(file1).read_text(encoding="utf-8")
self.assertEqual(content, "one\ntwo\nthree\n")
Expand Down

0 comments on commit 97051b9

Please sign in to comment.