def test_clipboard_blacklist(clipboard_manager):
    """Test widget hides selection from blacklisted windows."""
    widget = clipboard_manager.c.widget["clipboard"]
    assert widget.info()["text"] == ""

    clipboard_manager.test_window("Blacklisted Window")
    windows = clipboard_manager.c.windows()
    window_id = [w for w in windows if w["name"] == "Blacklisted Window"][0]["id"]

    fake_hook = textwrap.dedent(
        f"""
        from libqtile import hook

        sel = {{"owner": {window_id}, "selection": "Test Clipboard"}}

        hook.fire("selection_change", "CLIPBOARD", sel)
        hook.fire("selection_notify", "CLIPBOARD", sel)
    """
    )

    clipboard_manager.c.eval(fake_hook)

    # Widget should now show full text
    assert widget.info()["text"] == "***********"
Test widget hides selection from blacklisted windows.
test/widgets/test_clipboard.py