def test_command_set_invalid_command(caplog, fake_qtile):
    """Where the key is not in "commands", no command will be run."""
    extension = CommandSet(
        pre_commands=["run pre-command"], commands={"missing": "run testcommand"}
    )
    extension._configure(fake_qtile)
    extension.run()

    assert caplog.record_tuples == [("libqtile", logging.WARNING, "run pre-command")]
Where the key is not in "commands", no command will be run.
test/extension/test_command_set.py