mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 01:35:00 +00:00
aider: Added test method test_check_for_ctags_failure
that patches subprocess.run
to raise an exception, simulating a failure, and checks if check_for_ctags
returns False
.
# Context: USER: in tests/test_repomap.py add a test for check_for_ctags which patches subprocess to fail. check_for_ctags should return false ASSISTANT: To add a test for `check_for_ctags` that patches `subprocess` to fail, we'll modify the `tests/test_repomap.py` file. We'll use the `unittest.mock` library to patch the `subprocess.run` function to simulate a failure. Here's the change: ```python tests/test_repomap.py <<<<<<< ORIGINAL def test_get_tags_map_without_ctags(self): ======= from unittest.mock import patch def test_check_for_ctags_failure(self): with patch("subprocess.run") as mock_run: mock_run.side_effect = Exception("ctags not found") repo_map = RepoMap(use_ctags=True) result = repo_map.check_for_ctags() self.assertFalse(result) def test_get_tags_map_without_ctags(self): >>>>>>> UPDATED ``` This adds a new test method `test_check_for_ctags_failure` that patches `subprocess.run` to raise an exception, simulating a failure. The test then checks if `check_for_ctags` returns `False`.
This commit is contained in:
parent
e78ea4299f
commit
f2a116e0e1
1 changed files with 9 additions and 0 deletions
|
@ -55,6 +55,15 @@ def my_function(arg1, arg2):
|
|||
self.assertIn("my_method", result)
|
||||
self.assertIn("my_function", result)
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
def test_check_for_ctags_failure(self):
|
||||
with patch("subprocess.run") as mock_run:
|
||||
mock_run.side_effect = Exception("ctags not found")
|
||||
repo_map = RepoMap(use_ctags=True)
|
||||
result = repo_map.check_for_ctags()
|
||||
self.assertFalse(result)
|
||||
|
||||
def test_get_tags_map_without_ctags(self):
|
||||
# Create a temporary directory with a sample Python file containing identifiers
|
||||
test_files = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue