def test_keys_to_press(): assert list(_keys_to_press(G, "A", "A")) == [] assert list(_keys_to_press(G, "A", "B")) == ["KEY_RIGHT"] assert list(_keys_to_press(G, "B", "A")) == ["KEY_LEFT"] assert list(_keys_to_press(G, "A", "C")) == ["KEY_RIGHT", "KEY_RIGHT"] assert list(_keys_to_press(G, "C", "A")) == ["KEY_LEFT", "KEY_LEFT"] assert list(_keys_to_press(G, "A", "H")) == ["KEY_DOWN"] assert list(_keys_to_press(G, "H", "A")) == ["KEY_UP"] assert list(_keys_to_press(G, "A", "I")) in (["KEY_RIGHT", "KEY_DOWN"], ["KEY_DOWN", "KEY_RIGHT"]) assert list(_keys_to_press(G, " ", "A")) == ["KEY_UP"]
def test_keys_to_press(g): assert list(_keys_to_press(g, "A", "A")) == [] assert list(_keys_to_press(g, "A", "B")) == [("KEY_RIGHT", {"B"})] assert list(_keys_to_press(g, "B", "A")) == [("KEY_LEFT", {"A"})] assert list(_keys_to_press(g, "A", "C")) == [("KEY_RIGHT", {"B"}), ("KEY_RIGHT", {"C"})] assert list(_keys_to_press(g, "C", "A")) == [("KEY_LEFT", {"B"}), ("KEY_LEFT", {"A"})] assert list(_keys_to_press(g, "A", "H")) == [("KEY_DOWN", {"H"})] assert list(_keys_to_press(g, "H", "A")) == [("KEY_UP", {"A"})] assert list(_keys_to_press(g, "A", "I")) in ( [("KEY_RIGHT", {"B"}), ("KEY_DOWN", {"I"})], [("KEY_DOWN", {"H"}), ("KEY_RIGHT", {"I"})]) assert list(_keys_to_press(g, " ", "A")) == [ ("KEY_UP", {"V", "W", "X", "Y", "Z", "-", "'"})]
def test_keyboard_with_hash_sign(): """Regression test. `networkx.parse_edgelist` treats "#" as a comment.""" kb = stbt.Keyboard(""" @hotmail.com !#$ KEY_DOWN @hotmail.com @ KEY_DOWN @ # KEY_RIGHT # @ KEY_LEFT L K KEY_LEFT K L KEY_RIGHT """) keys = list(_keys_to_press(kb.G, "@hotmail.com", "@")) assert keys == [('KEY_DOWN', {'@', '!#$'})] assert list(_keys_to_press(kb.G, "@", "#")) == [('KEY_RIGHT', {'#'})] assert list(_keys_to_press(kb.G, "#", "@")) == [('KEY_LEFT', {'@'})] # L is the first character of the random comments delimiter in # `Keyboard.parse_edgelist`. Check that networkx uses the whole string, not # just the first character. assert list(_keys_to_press(kb.G, "K", "L")) == [('KEY_RIGHT', {'L'})] assert list(_keys_to_press(kb.G, "L", "K")) == [('KEY_LEFT', {'K'})]