diff --git a/tests/basic/test_main.py b/tests/basic/test_main.py index c3469a030..209c7045e 100644 --- a/tests/basic/test_main.py +++ b/tests/basic/test_main.py @@ -664,16 +664,18 @@ class TestMain(TestCase): mock_io_instance.prompt_ask.assert_not_called() @patch("aider.main.InputOutput") - @patch("aider.main.Path") - def test_setup_git_home_invalid_choice(self, mock_path, mock_io): + def test_setup_git_home_invalid_choice(self, mock_io): mock_io_instance = mock_io.return_value mock_io_instance.prompt_ask.side_effect = ["3", "1"] - mock_path.home.return_value.glob.return_value = [ - Path("/home/user/repo1/.git"), - Path("/home/user/repo2/.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 and repo2 subdirectories with .git folders + Path(temp_home, "repo1", ".git").mkdir(parents=True) + Path(temp_home, "repo2", ".git").mkdir(parents=True) - self.assertEqual(result, Path("/home/user/repo1")) - mock_io_instance.tool_error.assert_called_with("Please enter a number between 1 and 2") + result = setup_git_home(mock_io_instance) + + self.assertEqual(result, Path(temp_home) / "repo1") + mock_io_instance.tool_error.assert_called_with("Please enter a number between 1 and 2") + mock_io_instance.tool_output.assert_called_with("Found git repositories in your home directory:")