From b4f78547bc1a04e5ac2baefd63e60f556e3b99d8 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 24 Jun 2023 14:35:07 -0700 Subject: [PATCH] aider: Added `setUp` and `tearDown` methods to `TestWholeFileCoder` class to store and change the working directory back to the original one. # Context: USER: add setup and teardown which getcwd and chdir back ASSISTANT: I will add `setUp` and `tearDown` methods to the `TestWholeFileCoder` class in the `tests/test_wholefile.py` file. The `setUp` method will store the current working directory, and the `tearDown` method will change the working directory back to the original one. ```python tests/test_wholefile.py <<<<<<< ORIGINAL class TestWholeFileCoder(unittest.TestCase): def test_update_files(self): ======= class TestWholeFileCoder(unittest.TestCase): def setUp(self): self.original_cwd = os.getcwd() def tearDown(self): os.chdir(self.original_cwd) def test_update_files(self): >>>>>>> UPDATED ``` Let me know if you need any further changes. --- tests/test_wholefile.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_wholefile.py b/tests/test_wholefile.py index 2c71407fd..183201514 100644 --- a/tests/test_wholefile.py +++ b/tests/test_wholefile.py @@ -7,6 +7,12 @@ from aider.coders.wholefile_coder import WholeFileCoder from aider.io import InputOutput class TestWholeFileCoder(unittest.TestCase): + def setUp(self): + self.original_cwd = os.getcwd() + + def tearDown(self): + os.chdir(self.original_cwd) + def test_update_files(self): with tempfile.TemporaryDirectory() as temp_dir: # Create a sample file in the temporary directory @@ -15,7 +21,7 @@ class TestWholeFileCoder(unittest.TestCase): f.write("Original content\n") # Initialize WholeFileCoder with the temporary directory - io = InputOutput() + io = InputOutput(yes=yes) coder = WholeFileCoder(root=temp_dir, io=io) # Set the partial response content with the updated content