mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
aider: Added a new file that imports MyClass and calls both its methods to test_get_repo_map_with_identifiers.
# Context: USER: in `test_get_repo_map_with_identifiers` make a 2nd file that imports MyClass and calls both its methods. add that to `other_files` ASSISTANT: Here are the changes you need to make: 1. Modify `test_get_repo_map_with_identifiers` in `tests/test_repomap.py` to add a new file that imports `MyClass` and calls both its methods: ```python tests/test_repomap.py <<<<<<< ORIGINAL def test_get_repo_map_with_identifiers(self): # Create a temporary directory with a sample Python file containing identifiers test_file = "test_file_with_identifiers.py" file_content = """\ class MyClass: def my_method(self, arg1, arg2): return arg1 + arg2 def my_function(arg1, arg2): return arg1 * arg2 """ with tempfile.TemporaryDirectory() as temp_dir: with open(os.path.join(temp_dir, test_file), "w") as f: f.write(file_content) repo_map = RepoMap(root=temp_dir) other_files = [os.path.join(temp_dir, test_file), os.path.join(temp_dir, "test_file_import.py")] result = repo_map.get_repo_map([], other_files) # Check if the result contains the expected tags map with identifiers self.assertIn("test_file_with_identifiers.py", result) self.assertIn("MyClass", result) self.assertIn("my_method", result) self.assertIn("my_function", result) ======= def test_get_repo_map_with_identifiers(self): # Create a temporary directory with a sample Python file containing identifiers test_file1 = "test_file_with_identifiers.py" file_content1 = """\ class MyClass: def my_method(self, arg1, arg2): return arg1 + arg2 def my_function(arg1, arg2): return arg1 * arg2 """ test_file2 = "test_file_import.py" file_content2 = """\ from test_file_with_identifiers import MyClass obj = MyClass() print(obj.my_method(1, 2)) print(my_function(3, 4)) """ with tempfile.TemporaryDirectory() as temp_dir: with open(os.path.join(temp_dir, test_file1), "w") as f: f.write(file_content1) with open(os.path.join(temp_dir, test_file2), "w") as f: f.write(file_content2) repo_map = RepoMap(root=temp_dir) other_files = [os.path.join(temp_dir, test_file1), os.path.join(temp_dir, test_file2)] result = repo_map.get_repo_map([], other_files) # Check if the result contains the expected tags map with identifiers self.assertIn("test_file_with_identifiers.py", result) self.assertIn("MyClass", result) self.assertIn("my_method", result) self.assertIn("my_function", result) >>>>>>> UPDATED ``` 2. Run the tests to make sure everything is working as expected.
This commit is contained in:
parent
95cb482938
commit
5a61e6acd2
1 changed files with 17 additions and 6 deletions
|
@ -34,8 +34,8 @@ class TestRepoMap(unittest.TestCase):
|
|||
|
||||
def test_get_repo_map_with_identifiers(self):
|
||||
# Create a temporary directory with a sample Python file containing identifiers
|
||||
test_file = "test_file_with_identifiers.py"
|
||||
file_content = """\
|
||||
test_file1 = "test_file_with_identifiers.py"
|
||||
file_content1 = """\
|
||||
class MyClass:
|
||||
def my_method(self, arg1, arg2):
|
||||
return arg1 + arg2
|
||||
|
@ -44,12 +44,24 @@ def my_function(arg1, arg2):
|
|||
return arg1 * arg2
|
||||
"""
|
||||
|
||||
test_file2 = "test_file_import.py"
|
||||
file_content2 = """\
|
||||
from test_file_with_identifiers import MyClass
|
||||
|
||||
obj = MyClass()
|
||||
print(obj.my_method(1, 2))
|
||||
print(my_function(3, 4))
|
||||
"""
|
||||
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
with open(os.path.join(temp_dir, test_file), "w") as f:
|
||||
f.write(file_content)
|
||||
with open(os.path.join(temp_dir, test_file1), "w") as f:
|
||||
f.write(file_content1)
|
||||
|
||||
with open(os.path.join(temp_dir, test_file2), "w") as f:
|
||||
f.write(file_content2)
|
||||
|
||||
repo_map = RepoMap(root=temp_dir)
|
||||
other_files = [os.path.join(temp_dir, test_file)]
|
||||
other_files = [os.path.join(temp_dir, test_file1), os.path.join(temp_dir, test_file2)]
|
||||
result = repo_map.get_repo_map([], other_files)
|
||||
|
||||
# Check if the result contains the expected tags map with identifiers
|
||||
|
@ -57,7 +69,6 @@ def my_function(arg1, arg2):
|
|||
self.assertIn("MyClass", result)
|
||||
self.assertIn("my_method", result)
|
||||
self.assertIn("my_function", result)
|
||||
|
||||
def test_check_for_ctags_failure(self):
|
||||
with patch("subprocess.run") as mock_run:
|
||||
mock_run.side_effect = Exception("ctags not found")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue