def on_cleanup_error(function, path, excinfo):
                click.secho("warning: failed to remove file or directory: {}\n"
                            "please delete it manually.".format(path),
                            fg="red")
def patched_cnli(monkeypatch):
    MockCapsNumLockIndicator.reset()
    monkeypatch.setattr(
        "libqtile.widget.caps_num_lock_indicator.subprocess", MockCapsNumLockIndicator
    )
    monkeypatch.setattr(
        "libqtile.widget.caps_num_lock_indicator.subprocess.CalledProcessError",
        subprocess.CalledProcessError,
    )

    monkeypatch.setattr(
        "libqtile.widget.caps_num_lock_indicator.base.ThreadPoolText.call_process",
        MockCapsNumLockIndicator.call_process,
    )
    return caps_num_lock_indicator