def METHOD_NAME(tree, tmp_path, mocker, event, check_error):
    if event == "<<Copy>>":
        shutil_mock = mocker.patch("porcupine.plugins.filemanager.shutil").copy
        copy_or_move = "copy"
        copying_or_moving = "copying"
    else:
        shutil_mock = mocker.patch("porcupine.plugins.filemanager.shutil").move
        copy_or_move = "move"
        copying_or_moving = "moving"
    shutil_mock.side_effect = PermissionError("[Errno 13] Permission denied: '/dev/xyz'")
    mocker.patch("porcupine.plugins.filemanager.ask_file_name").return_value = tmp_path / "bar"
    mocker.patch("tkinter.messagebox.showerror")
    (tmp_path / "foo").write_text("hello")
    add_project_and_select_file(tmp_path / "foo")
    tree.event_generate(event)
    tree.event_generate("<<Paste>>")
    check_error(
        copying_or_moving.capitalize() + " failed",
        f"Cannot {copy_or_move} {tmp_path / 'foo'} to {tmp_path / 'bar'}.",
        "PermissionError: [Errno 13] Permission denied: '/dev/xyz'",
    )