From 55ce3b57748b9d7749c36c4e92c06dd8dedd6476 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 5 Apr 2025 22:39:41 +0000 Subject: [PATCH] Add edge case tests for path_utils Co-Authored-By: Joe Moura --- tests/utilities/test_path_utils.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/utilities/test_path_utils.py b/tests/utilities/test_path_utils.py index 7dfb1e41e..ce3905758 100644 --- a/tests/utilities/test_path_utils.py +++ b/tests/utilities/test_path_utils.py @@ -41,7 +41,7 @@ class TestPathUtils(unittest.TestCase): @patch('pathlib.Path.exists') def test_add_project_to_path_without_src(self, mock_exists, mock_getcwd): mock_getcwd.return_value = "/home/user/project" - mock_exists.return_value = False + mock_exists.side_effect = [True, False] original_sys_path = sys.path.copy() @@ -78,3 +78,23 @@ class TestPathUtils(unittest.TestCase): self.assertIn(os.path.join(custom_dir, "src"), sys.path) finally: sys.path = original_sys_path + + @patch('pathlib.Path.exists') + def test_add_project_to_path_with_nonexistent_dir(self, mock_exists): + mock_exists.return_value = False + + with self.assertRaises(ValueError): + add_project_to_path("/nonexistent/path") + + @patch('os.getcwd') + @patch('pathlib.Path.exists') + def test_add_project_to_path_with_nonexistent_cwd(self, mock_exists, mock_getcwd): + mock_getcwd.return_value = "/nonexistent/path" + mock_exists.return_value = False + + with self.assertRaises(ValueError): + add_project_to_path() + + def test_add_project_to_path_with_empty_string(self): + with self.assertRaises(ValueError): + add_project_to_path("")