style: Format code according to linter rules

This commit is contained in:
Paul Gauthier (aider) 2025-03-22 13:23:52 -07:00
parent 3b376a15b7
commit 7e51c68fde

View file

@ -312,52 +312,53 @@ class TestCoder(unittest.TestCase):
test_cases = [
# Simple plain text mentions
(f"You should edit {test_files[0]} first", {test_files[0]}),
# Multiple files in plain text
(f"Edit both {test_files[0]} and {test_files[1]}", {test_files[0], test_files[1]}),
# Files in backticks
(f"Check the file `{test_files[2]}`", {test_files[2]}),
# Files in code blocks
(f"```\n{test_files[3]}\n```", {test_files[3]}),
# Files in code blocks with language specifier
(f"```python\nwith open('{test_files[1]}', 'r') as f:\n data = f.read()\n```", {test_files[1]}),
(
f"```python\nwith open('{test_files[1]}', 'r') as f:\n data = f.read()\n```",
{test_files[1]},
),
# Files with Windows-style paths
(f"Edit the file {test_files[2].replace('/', '\\')}", {test_files[2]}),
# Files with spaces
(f"Look at '{test_files[4]}'", {test_files[4]}),
# Files with different quote styles
(f'Check "{test_files[5]}" now', {test_files[5]}),
# Files mentioned in markdown links
(f"See the file [{test_files[0]}]({test_files[0]})", {test_files[0]}),
# All files in one complex message
(
(
f"First, edit `{test_files[0]}`. Then modify {test_files[1]}.\n"
f"```js\n// Update this file\nconst file = '{test_files[2]}';\n```\n"
f"Finally check {test_files[3].replace('/', '\\')}",
{test_files[0], test_files[1], test_files[2], test_files[3]}
f"Finally check {test_files[3].replace('/', '\\')}"
),
{test_files[0], test_files[1], test_files[2], test_files[3]},
),
# Mention with SEARCH/REPLACE format
(
f"{test_files[1]}\n````python\n<<<<<<< SEARCH\ndef old_function():\n pass\n=======\n"
f"def new_function():\n return True\n>>>>>>> REPLACE\n````",
{test_files[1]}
(
f"{test_files[1]}\n````python\n<<<<<<< SEARCH\ndef old_function():\n "
" pass\n=======\ndef new_function():\n return True\n>>>>>>>"
" REPLACE\n````"
),
{test_files[1]},
),
]
for content, expected_mentions in test_cases:
with self.subTest(content=content):
mentioned_files = coder.get_file_mentions(content)
self.assertEqual(mentioned_files, expected_mentions,
f"Failed to extract mentions from: {content}")
self.assertEqual(
mentioned_files,
expected_mentions,
f"Failed to extract mentions from: {content}",
)
def test_get_file_mentions_path_formats(self):
with GitTemporaryDirectory():