mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
aider: Added a test for the cmd_drop
method with glob patterns in the TestCommands
class.
# Context: USER: add a test for that ASSISTANT: To add a test for the `cmd_drop` method with glob patterns, we need to modify the `tests/test_commands.py` file. Here's the step-by-step process: 1. Add a new test method `test_cmd_drop_with_glob_patterns` in the `TestCommands` class. 2. In this method, initialize the `Commands` and `InputOutput` objects. 3. Add some files to the chat session. 4. Call the `cmd_drop` method with a glob pattern. 5. Check if the correct files have been removed from the chat session. Here's the code change: ```python tests/test_commands.py <<<<<<< ORIGINAL def test_cmd_add_no_match(self): # Initialize the Commands and InputOutput objects io = InputOutput(pretty=False, yes=True) from aider.coders import Coder coder = Coder.create(models.GPT35, None, io, openai_api_key="deadbeef") commands = Commands(io, coder) # Call the cmd_add method with a non-existent file pattern commands.cmd_add("*.nonexistent") # Check if no files have been added to the chat session self.assertEqual(len(coder.abs_fnames), 0) ======= def test_cmd_add_no_match(self): # Initialize the Commands and InputOutput objects io = InputOutput(pretty=False, yes=True) from aider.coders import Coder coder = Coder.create(models.GPT35, None, io, openai_api_key="deadbeef") commands = Commands(io, coder) # Call the cmd_add method with a non-existent file pattern commands.cmd_add("*.nonexistent") # Check if no files have been added to the chat session self.assertEqual(len(coder.abs_fnames), 0) def test_cmd_drop_with_glob_patterns(self): # Initialize the Commands and InputOutput objects io = InputOutput(pretty=False, yes=True) from aider.coders import Coder coder = Coder.create(models.GPT35, None, io, openai_api_key="deadbeef") commands = Commands(io, coder) # Add some files to the chat session commands.cmd_add("*.py") # Call the cmd_drop method with a glob pattern commands.cmd_drop("*.py") # Check if the Python files have been removed from the chat session self.assertNotIn(os.path.abspath("test1.py"), coder.abs_fnames) self.assertNotIn(os.path.abspath("test2.py"), coder.abs_fnames) >>>>>>> UPDATED ``` Please let me know if you need any further changes.
This commit is contained in:
parent
ad5cdc463a
commit
7f76559e6c
1 changed files with 18 additions and 0 deletions
|
@ -57,3 +57,21 @@ class TestCommands(TestCase):
|
|||
|
||||
# Check if no files have been added to the chat session
|
||||
self.assertEqual(len(coder.abs_fnames), 0)
|
||||
|
||||
def test_cmd_drop_with_glob_patterns(self):
|
||||
# Initialize the Commands and InputOutput objects
|
||||
io = InputOutput(pretty=False, yes=True)
|
||||
from aider.coders import Coder
|
||||
|
||||
coder = Coder.create(models.GPT35, None, io, openai_api_key="deadbeef")
|
||||
commands = Commands(io, coder)
|
||||
|
||||
# Add some files to the chat session
|
||||
commands.cmd_add("*.py")
|
||||
|
||||
# Call the cmd_drop method with a glob pattern
|
||||
commands.cmd_drop("*.py")
|
||||
|
||||
# Check if the Python files have been removed from the chat session
|
||||
self.assertNotIn(os.path.abspath("test1.py"), coder.abs_fnames)
|
||||
self.assertNotIn(os.path.abspath("test2.py"), coder.abs_fnames)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue