From b8a52c2bef5f5dff8a3b7138a2e67299390fd83f Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 28 Aug 2024 15:27:03 -0700 Subject: [PATCH] feat: use IgnorantTemporaryDirectory and create actual repo1 subdirectory in test_setup_git_home_existing_repo --- tests/basic/test_main.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/basic/test_main.py b/tests/basic/test_main.py index 0a9db8cbd..edbc52202 100644 --- a/tests/basic/test_main.py +++ b/tests/basic/test_main.py @@ -621,19 +621,22 @@ class TestMain(TestCase): self.assertTrue(coder.suggest_shell_commands) @patch("aider.main.InputOutput") - @patch("aider.main.Path") - def test_setup_git_home_existing_repo(self, mock_path, mock_io): + def test_setup_git_home_existing_repo(self, mock_io): mock_io_instance = mock_io.return_value mock_io_instance.prompt_ask.return_value = "1" - mock_path.home.return_value.glob.return_value = [Path("/home/user/repo1/.git")] - result = setup_git_home(mock_io_instance) + with IgnorantTemporaryDirectory() as temp_home: + with patch("aider.main.Path.home", return_value=Path(temp_home)): + # Create actual repo1 subdirectory with .git folder + Path(temp_home, "repo1", ".git").mkdir(parents=True) - self.assertEqual(result, Path("/home/user/repo1")) - mock_io_instance.tool_output.assert_called_with( - "Found git repositories in your home directory:" - ) - mock_io_instance.prompt_ask.assert_called() + result = setup_git_home(mock_io_instance) + + self.assertEqual(result, Path(temp_home) / "repo1") + mock_io_instance.tool_output.assert_any_call( + "Found git repositories in your home directory:" + ) + mock_io_instance.prompt_ask.assert_called() @patch("aider.main.InputOutput") @patch("aider.main.make_new_repo")