mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 00:05:01 +00:00
aider: Changed test_main_with_ctags_mocked_failure to run within a temporary directory.
# Context: USER: we need to cwd into a temp dir before the test ASSISTANT: To change the working directory to a temporary directory before running the test, you can use the `tempfile.TemporaryDirectory()` context manager in the `test_main_with_ctags_mocked_failure` method. Here's the updated code for `tests/test_main.py`: ```python tests/test_main.py <<<<<<< ORIGINAL def test_main_with_ctags_mocked_failure(self): with patch("subprocess.run", side_effect=subprocess.CalledProcessError(1, "ctags")): with patch("aider.main.Coder") as MockCoder: main(["--ctags"]) _, kwargs = MockCoder.call_args assert kwargs["use_ctags"] is False ======= def test_main_with_ctags_mocked_failure(self): with tempfile.TemporaryDirectory() as temp_dir: os.chdir(temp_dir) with patch("subprocess.run", side_effect=subprocess.CalledProcessError(1, "ctags")): with patch("aider.main.Coder") as MockCoder: main(["--ctags"]) _, kwargs = MockCoder.call_args assert kwargs["use_ctags"] is False >>>>>>> UPDATED ``` This change will ensure that the test is run within a temporary directory.
This commit is contained in:
parent
640479dafb
commit
3b23efa4d8
1 changed files with 7 additions and 5 deletions
|
@ -82,8 +82,10 @@ class TestMain(TestCase):
|
|||
assert kwargs["dirty_commits"] is True
|
||||
|
||||
def test_main_with_ctags_mocked_failure(self):
|
||||
with patch("subprocess.run", side_effect=subprocess.CalledProcessError(1, "ctags")):
|
||||
with patch("aider.main.Coder") as MockCoder:
|
||||
main(["--ctags"])
|
||||
_, kwargs = MockCoder.call_args
|
||||
assert kwargs["use_ctags"] is False
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
os.chdir(temp_dir)
|
||||
with patch("subprocess.run", side_effect=subprocess.CalledProcessError(1, "ctags")):
|
||||
with patch("aider.main.Coder") as MockCoder:
|
||||
main(["--ctags"])
|
||||
_, kwargs = MockCoder.call_args
|
||||
assert kwargs["use_ctags"] is False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue