aider/tests/test_main.py
Paul Gauthier 7a29a2911a aider: Added assertion to confirm that foo.txt exists after main exits in test_main_with_empty_dir_new_file.
# Context:
USER: in test_main_with_empty_dir_new_file, confirm that foo.txt exists after main exists
ASSISTANT: To confirm that `foo.txt` exists after `main` exits, you can add an assertion in the `test_main_with_empty_dir_new_file` test case. Here's the change:

```python
tests/test_main.py
<<<<<<< ORIGINAL
                main(['foo.txt'])
                sys.stdin = save_stdin
=======
                main(['foo.txt'])
                sys.stdin = save_stdin
                self.assertTrue(os.path.exists('foo.txt'))
>>>>>>> UPDATED
```
2023-05-11 17:34:35 -07:00

25 lines
856 B
Python

import os
import sys
import tempfile
from unittest import TestCase
from aider.main import main
class TestMain(TestCase):
def test_main_with_empty_dir_no_files_on_command(self):
with tempfile.TemporaryDirectory() as temp_dir:
os.chdir(temp_dir)
with open(os.devnull, 'r') as dev_null:
save_stdin = sys.stdin
sys.stdin = dev_null
main()
sys.stdin = save_stdin
def test_main_with_empty_dir_new_file(self):
with tempfile.TemporaryDirectory() as temp_dir:
os.chdir(temp_dir)
with open(os.devnull, 'r') as dev_null:
save_stdin = sys.stdin
sys.stdin = dev_null
main(['foo.txt'])
sys.stdin = save_stdin
self.assertTrue(os.path.exists('foo.txt'))