File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ def validate_browser_paths(paths: list[str]) -> str:
159159 InvalidBrowserPath: If the browser executable is not found at the path.
160160 """
161161 for path in paths :
162- if os .path .exists (path ) and os .access (path , os .X_OK ):
162+ if os .path .isfile (path ) and os .access (path , os .X_OK ):
163163 return path
164164 raise InvalidBrowserPath (f'No valid browser path found in: { paths } ' )
165165
Original file line number Diff line number Diff line change @@ -206,6 +206,17 @@ def test_validate_browser_paths_file_exists_but_not_executable(self):
206206 with pytest .raises (exceptions .InvalidBrowserPath ):
207207 validate_browser_paths ([non_executable ])
208208
209+ @pytest .mark .skipif (sys .platform .startswith ('win' ), reason = 'No executable bit on NTFS on Windows' )
210+ def test_validate_browser_paths_directory_instead_of_file (self ):
211+ """
212+ Test validate_browser_paths with a directory path.
213+ Verifies that directories are not treated as valid executables even if they have execute permission.
214+ """
215+ with tempfile .TemporaryDirectory () as temp_dir :
216+ os .chmod (temp_dir , 0o755 )
217+ with pytest .raises (exceptions .InvalidBrowserPath ):
218+ validate_browser_paths ([temp_dir ])
219+
209220 def test_validate_browser_paths_empty_list (self ):
210221 """
211222 Test validate_browser_paths with empty path list.
You can’t perform that action at this time.
0 commit comments