diff --git a/tests/basic/test_coder.py b/tests/basic/test_coder.py index 8fa5d6426..4abb624c3 100644 --- a/tests/basic/test_coder.py +++ b/tests/basic/test_coder.py @@ -366,6 +366,45 @@ class TestCoder(unittest.TestCase): 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): with GitTemporaryDirectory(): io = InputOutput(pretty=False, yes=True)