mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 05:45:00 +00:00
fix: Improve filename detection in find_filename function
This commit is contained in:
parent
a716fda897
commit
66e9c3834a
2 changed files with 10 additions and 12 deletions
|
@ -18,23 +18,19 @@ class TestUtils(unittest.TestCase):
|
|||
|
||||
def test_find_filename(self):
|
||||
fence = ("```", "```")
|
||||
valid_fnames = ["file1.py", "file2.py", "dir/file3.py"]
|
||||
valid_fnames = ["file1.py", "file2.py", "dir/file3.py", "\windows\__init__.py"]
|
||||
|
||||
# Test with filename on a single line
|
||||
lines = ["file1.py", "```"]
|
||||
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "file1.py")
|
||||
|
||||
# Test with filename and fence on separate lines
|
||||
lines = ["file2.py", "```", "some content"]
|
||||
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "file2.py")
|
||||
|
||||
# Test with filename in fence
|
||||
lines = ["```python", "file3.py", "```"]
|
||||
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "dir/file3.py")
|
||||
|
||||
# Test with no valid filename
|
||||
lines = ["```", "invalid_file.py", "```"]
|
||||
self.assertIsNone(eb.find_filename(lines, fence, valid_fnames))
|
||||
self.assertEqual("invalid_file.py", eb.find_filename(lines, fence, valid_fnames))
|
||||
|
||||
# Test with multiple fences
|
||||
lines = ["```python", "file1.py", "```", "```", "file2.py", "```"]
|
||||
|
@ -48,6 +44,10 @@ class TestUtils(unittest.TestCase):
|
|||
lines = ["file1_py", "```"]
|
||||
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "file1.py")
|
||||
|
||||
# Test with fuzzy matching
|
||||
lines = ["\windows__init__.py", "```"]
|
||||
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "\windows\__init__.py")
|
||||
|
||||
# fuzzy logic disabled v0.11.2-dev
|
||||
def __test_replace_most_similar_chunk(self):
|
||||
whole = "This is a sample text.\nAnother line of text.\nYet another line.\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue