def test_dmenu_run(monkeypatch): def fake_popen(cmd, *args, **kwargs): class PopenObj: def communicate(self, value_in, *args): return [value_in, None] return PopenObj() monkeypatch.setattr("libqtile.extension.base.Popen", fake_popen) # dmenu_lines is set to the lower of config value and len(items) so set a high value now extension = Dmenu(dmenu_lines=5) extension._configure(None) items = ["test1", "test2"] assert extension.run(items) == "test1\ntest2\n" # dmenu_lines should be length of items assert extension.configured_command[-2:] == ["-l", "2"]
def test_dmenu_configuration_options(): """ Test that configuration options are correctly translated into command options for dmenu. """ _Extension.global_defaults = {} opts = [ ({}, ["dmenu"]), ({ "dmenu_command": "testdmenu --test-option" }, ["testdmenu", "--test-option"]), ({ "dmenu_command": ["testdmenu", "--test-option"] }, ["testdmenu", "--test-option"]), ({}, ["-fn", "sans"]), ({ "dmenu_font": "testfont" }, ["-fn", "testfont"]), ({ "font": "testfont" }, ["-fn", "testfont"]), ({ "font": "testfont", "fontsize": 12 }, ["-fn", "testfont-12"]), ({ "dmenu_bottom": True }, ["-b"]), ({ "dmenu_ignorecase": True }, ["-i"]), ({ "dmenu_lines": 5 }, ["-l", "5"]), ({ "dmenu_prompt": "testprompt" }, ["-p", "testprompt"]), ({ "background": BLACK }, ["-nb", BLACK]), ({ "foreground": BLACK }, ["-nf", BLACK]), ({ "selected_background": BLACK }, ["-sb", BLACK]), ({ "selected_foreground": BLACK }, ["-sf", BLACK]), ({ "dmenu_height": 100 }, ["-h", "100"]), ] # Loop over options, create an instance of Dmenu with the provided "config" # find the index of the first item in "output" and check any following items # match the expected output for config, output in opts: extension = Dmenu(**config) extension._configure(None) index = extension.configured_command.index(output[0]) assert output == extension.configured_command[index:index + len(output)]
def __init__(self, **config): Dmenu.__init__(self, **config) self.add_defaults(WindowList.defaults)
def _configure(self, qtile): Dmenu._configure(self, qtile)
def __init__(self, **config): Dmenu.__init__(self, **config) self.add_defaults(CommandSet.defaults)