mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
test: add test for multiline backtick file mentions
This commit is contained in:
parent
f46deb4eb7
commit
c580ffdb70
1 changed files with 39 additions and 0 deletions
|
@ -366,6 +366,45 @@ class TestCoder(unittest.TestCase):
|
||||||
f"Failed to extract mentions from: {content}",
|
f"Failed to extract mentions from: {content}",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_get_file_mentions_multiline_backticks(self):
|
||||||
|
with GitTemporaryDirectory():
|
||||||
|
io = InputOutput(pretty=False, yes=True)
|
||||||
|
coder = Coder.create(self.GPT35, None, io)
|
||||||
|
|
||||||
|
# Create test files
|
||||||
|
test_files = [
|
||||||
|
"swebench/harness/test_spec/python.py",
|
||||||
|
"swebench/harness/test_spec/javascript.py",
|
||||||
|
]
|
||||||
|
for fname in test_files:
|
||||||
|
fpath = Path(fname)
|
||||||
|
fpath.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
fpath.touch()
|
||||||
|
|
||||||
|
# Mock get_addable_relative_files to return our test files
|
||||||
|
coder.get_addable_relative_files = MagicMock(return_value=set(test_files))
|
||||||
|
|
||||||
|
# Input text with multiline backticked filenames
|
||||||
|
content = """
|
||||||
|
Could you please **add the following files to the chat**?
|
||||||
|
|
||||||
|
1. `swebench/harness/test_spec/python.py`
|
||||||
|
2. `swebench/harness/test_spec/javascript.py`
|
||||||
|
|
||||||
|
Once I have these, I can show you precisely how to do the thing.
|
||||||
|
"""
|
||||||
|
expected_mentions = {
|
||||||
|
"swebench/harness/test_spec/python.py",
|
||||||
|
"swebench/harness/test_spec/javascript.py",
|
||||||
|
}
|
||||||
|
|
||||||
|
mentioned_files = coder.get_file_mentions(content)
|
||||||
|
self.assertEqual(
|
||||||
|
mentioned_files,
|
||||||
|
expected_mentions,
|
||||||
|
f"Failed to extract mentions from multiline backticked content: {content}",
|
||||||
|
)
|
||||||
|
|
||||||
def test_get_file_mentions_path_formats(self):
|
def test_get_file_mentions_path_formats(self):
|
||||||
with GitTemporaryDirectory():
|
with GitTemporaryDirectory():
|
||||||
io = InputOutput(pretty=False, yes=True)
|
io = InputOutput(pretty=False, yes=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue