def test_unicode_decode_error_isWritable(self, path_mocker_stopall):
# mock
mock_os_path_isdir = path_mocker_stopall.MagicMock(name="mock_os_path_isdir")
mock_os_access = path_mocker_stopall.MagicMock(name="mock_os_access")
mock_unicode_error_dialog = path_mocker_stopall.MagicMock(name="mock_unicode_error_dialog")
mock_logger_error = path_mocker_stopall.MagicMock(name="mock_logger_error")
# patch
path_mocker_stopall.patch.object(scarlett_os.internal.path.os.path, 'isdir', mock_os_path_isdir)
path_mocker_stopall.patch.object(scarlett_os.internal.path.os, 'access', mock_os_access)
path_mocker_stopall.patch.object(scarlett_os.internal.path, 'unicode_error_dialog', mock_unicode_error_dialog)
path_mocker_stopall.patch.object(scarlett_os.subprocess.logging.Logger, 'error', mock_logger_error)
path = b'file:///tmp/fake_file'
# patch return values
mock_os_path_isdir.side_effect = UnicodeDecodeError('', b'', 1, 0, '')
s_path.isWritable(path)
assert mock_unicode_error_dialog.call_count == 1
评论列表
文章目录