@@ -259,20 +259,22 @@ def test_open_file_with_default_app_windows(self):
259259 with patch ('tkface.widget.pathbrowser.utils.IS_WINDOWS' , True ):
260260 with patch ('tkface.widget.pathbrowser.utils.IS_MACOS' , False ):
261261 with patch ('tkface.widget.pathbrowser.utils.IS_LINUX' , False ):
262- # Mock os.startfile by patching the module directly with create=True
263- with patch ('os.startfile' , create = True ) as mock_startfile :
262+ with patch ('tkface.widget.pathbrowser.utils.subprocess.run' ) as mock_run :
264263 result = utils .open_file_with_default_app ("C:\\ test\\ file.txt" )
265264 assert result is True
266- mock_startfile .assert_called_once_with ("C:\\ test\\ file.txt" )
265+ mock_run .assert_called_once_with (
266+ ["cmd" , "/c" , "start" , "" , "C:\\ test\\ file.txt" ],
267+ check = False ,
268+ shell = False
269+ )
267270
268271 def test_open_file_with_default_app_windows_exception (self ):
269272 """Test open_file_with_default_app function on Windows with exception."""
270273 with patch ('tkface.widget.pathbrowser.utils.IS_WINDOWS' , True ):
271274 with patch ('tkface.widget.pathbrowser.utils.IS_MACOS' , False ):
272275 with patch ('tkface.widget.pathbrowser.utils.IS_LINUX' , False ):
273- # Mock os.startfile by patching the module directly with create=True
274- with patch ('os.startfile' , create = True ) as mock_startfile :
275- mock_startfile .side_effect = Exception ("Access denied" )
276+ with patch ('tkface.widget.pathbrowser.utils.subprocess.run' ) as mock_run :
277+ mock_run .side_effect = Exception ("Access denied" )
276278 result = utils .open_file_with_default_app ("C:\\ test\\ file.txt" )
277279 assert result is False
278280
0 commit comments