mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
aider: Added subprocess
module to run git init
in the temporary directory before calling main
in test_main_with_empty_git_dir_new_file
.
# Context: USER: in test_main_with_empty_git_dir_new_file, run git init in the new dir before calling main ASSISTANT: To run `git init` in the new directory before calling `main`, you can use the `subprocess` module to execute the command. Here's the change you need to make in the `test_main_with_empty_git_dir_new_file` function: ```python tests/test_main.py <<<<<<< ORIGINAL def test_main_with_empty_git_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 ======= import subprocess def test_main_with_empty_git_dir_new_file(self): with tempfile.TemporaryDirectory() as temp_dir: os.chdir(temp_dir) subprocess.run(["git", "init"]) with open(os.devnull, 'r') as dev_null: save_stdin = sys.stdin sys.stdin = dev_null main(['foo.txt']) sys.stdin = save_stdin >>>>>>> UPDATED ``` This change imports the `subprocess` module and adds the `subprocess.run(["git", "init"])` line to run `git init` in the temporary directory before calling `main`.
This commit is contained in:
parent
7a29a2911a
commit
fa2f76c107
1 changed files with 12 additions and 0 deletions
|
@ -23,3 +23,15 @@ class TestMain(TestCase):
|
|||
main(['foo.txt'])
|
||||
sys.stdin = save_stdin
|
||||
self.assertTrue(os.path.exists('foo.txt'))
|
||||
|
||||
import subprocess
|
||||
|
||||
def test_main_with_empty_git_dir_new_file(self):
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
os.chdir(temp_dir)
|
||||
subprocess.run(["git", "init"])
|
||||
with open(os.devnull, 'r') as dev_null:
|
||||
save_stdin = sys.stdin
|
||||
sys.stdin = dev_null
|
||||
main(['foo.txt'])
|
||||
sys.stdin = save_stdin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue