mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 00:05:01 +00:00

# Context: USER: I ran this command: pytest tests/test_repomap.py And got this output: ============================= test session starts ============================== platform darwin -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0 rootdir: /Users/gauthier/Projects/aider collected 1 item tests/test_repomap.py F [100%] =================================== FAILURES =================================== ________________________ TestRepoMap.test_get_tags_map _________________________ self = <tests.test_repomap.TestRepoMap testMethod=test_get_tags_map> def test_get_tags_map(self): # Create a temporary directory with sample files for testing test_files = [ "test_file1.py", "test_file2.py", "test_file3.md", "test_file4.json", ] > with tempfile.TemporaryDirectory() as temp_dir: E NameError: name 'tempfile' is not defined tests/test_repomap.py:15: NameError =========================== short test summary info ============================ FAILED tests/test_repomap.py::TestRepoMap::test_get_tags_map - NameError: nam... ============================== 1 failed in 0.05s =============================== ASSISTANT: It looks like the `tempfile` module is not imported in the `tests/test_repomap.py` file. I will add the import statement for you. ```python tests/test_repomap.py <<<<<<< ORIGINAL import os import unittest from aider.repomap import RepoMap ======= import os import tempfile import unittest from aider.repomap import RepoMap >>>>>>> UPDATED ``` Now, you can run the test again with the `pytest tests/test_repomap.py` command.
32 lines
1 KiB
Python
32 lines
1 KiB
Python
import os
|
|
import tempfile
|
|
import unittest
|
|
from aider.repomap import RepoMap
|
|
|
|
class TestRepoMap(unittest.TestCase):
|
|
def test_get_tags_map(self):
|
|
# Create a temporary directory with sample files for testing
|
|
test_files = [
|
|
"test_file1.py",
|
|
"test_file2.py",
|
|
"test_file3.md",
|
|
"test_file4.json",
|
|
]
|
|
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
for file in test_files:
|
|
with open(os.path.join(temp_dir, file), "w") as f:
|
|
f.write("")
|
|
|
|
repo_map = RepoMap(root=temp_dir)
|
|
other_files = [os.path.join(temp_dir, file) for file in test_files]
|
|
result = repo_map.get_tags_map(other_files)
|
|
|
|
# Check if the result contains the expected tags map
|
|
self.assertIn("test_file1.py:", result)
|
|
self.assertIn("test_file2.py:", result)
|
|
self.assertNotIn("test_file3.md:", result)
|
|
self.assertNotIn("test_file4.json:", result)
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|