Skip to content

test_macos fails on check_keylayout("q-ansi") #222

@nojhan

Description

@nojhan

After having disabled mypy (because of issue #221), I get the following error:

$ poetry run make ruff format kalamine 16 files left unchanged ruff check --fix kalamine All checks passed! ruff format --check kalamine 16 files already formatted ruff check kalamine All checks passed! # mypy kalamine python3 -m kalamine.cli guide > docs/README.md python3 -m kalamine.cli build layouts/*.toml ... dist/q-ansi.ahk `us` is not a valid locale ... dist/q-ansi.klc ... dist/q-ansi.keylayout ... dist/q-ansi.xkb_keymap ... dist/q-ansi.xkb_symbols ... dist/q-ansi.json ... dist/q-ansi.svg ... dist/q-intl.ahk `us` is not a valid locale ... dist/q-intl.klc ... dist/q-intl.keylayout ... dist/q-intl.xkb_keymap ... dist/q-intl.xkb_symbols ... dist/q-intl.json ... dist/q-intl.svg ... dist/q-prog.ahk `us` is not a valid locale ... dist/q-prog.klc ... dist/q-prog.keylayout ... dist/q-prog.xkb_keymap ... dist/q-prog.xkb_symbols ... dist/q-prog.json ... dist/q-prog.svg python3 -m pytest ======================================= test session starts ======================================= platform darwin -- Python 3.10.9, pytest-8.4.1, pluggy-1.6.0 rootdir: /Users/nojhan/code/kalamine configfile: pyproject.toml collected 19 items tests/test_macos.py F [ 5%] tests/test_parser.py ... [ 21%] tests/test_serializer_ahk.py ... [ 36%] tests/test_serializer_keylayout.py ... [ 52%] tests/test_serializer_klc.py ...... [ 84%] tests/test_serializer_xkb.py ... [100%] ============================================ FAILURES ============================================= _________________________________________ test_keylayouts _________________________________________ def test_keylayouts(): > check_keylayout("q-ansi") tests/test_macos.py:82: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ filename = 'q-ansi' def check_keylayout(filename: str): path = Path(__file__).parent.parent / f"dist/{filename}.keylayout" tree = etree.parse(path, etree.XMLParser(recover=True)) dead_keys = [] # check all keymaps/layers: base, shift, caps, option, option+shift for keymap_index in range(5): keymap_query = f'//keyMap[@index="{keymap_index}"]' keymap = tree.xpath(keymap_query) assert len(keymap) == 1, f"{keymap_query} should be unique" # check all key codes for this keymap / layer # (the key codes below are not used, I don't know why) excluded_keys = [ 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 68, 73, 74, 90, 93, 94, 95, ] for key_index in range(126): if key_index in excluded_keys: continue # ensure the key is defined and unique key_query = f'{keymap_query}/key[@code="{key_index}"]' key = tree.xpath(key_query) assert len(key) == 1, f"{key_query} should be unique" # ensure the key has either a direct output or a valid action action_id = key[0].get("action") if action_id: if action_id.startswith("dead_"): dead_keys.append(action_id[5:]) action_query = f'//actions/action[@id="{action_id}"]' action = tree.xpath(action_query) assert len(action) == 1, f"{action_query} should be unique" assert ( len(action_id) > 1 ), f"{key_query} should have a multi-char action ID" else: assert ( > len(key[0].get("output")) <= 1 ), f"{key_query} should have a one-char output" E TypeError: object of type 'NoneType' has no len() tests/test_macos.py:60: TypeError ===================================== short test summary info ===================================== FAILED tests/test_macos.py::test_keylayouts - TypeError: object of type 'NoneType' has no len() ================================== 1 failed, 18 passed in 1.79s =================================== make: *** [test] Error 1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions