sde1000 / python-xkbcommon

Python bindings for libxkbcommon using cffi
MIT License
19 stars 5 forks source link

1.5.1: test_compose_table_new_from_locale hardcodes the use of en_GB.UTF-8 #25

Closed dvzrv closed 3 months ago

dvzrv commented 3 months ago

Hi! :wave:

I package this project for Arch Linux. When trying to upgrade to 1.5.1 I noticed that the test test_compose_table_new_from_locale hardcodes the use of en_GB.UTF-8.

This locale may not be readily available on downstreams by default and may not be settable without root rights (which our particular build environments don't have).

This leads to:

=================================== FAILURES ===================================
________________ TestContext.test_compose_table_new_from_locale ________________

self = <tests.test_xkb.TestContext testMethod=test_compose_table_new_from_locale>

    def test_compose_table_new_from_locale(self):
        ctx = xkb.Context()
>       ct = ctx.compose_table_new_from_locale("en_GB.UTF-8")

tests/test_xkb.py:169:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xkbcommon.xkb.Context object at 0x74387ca25880>, locale = 'en_GB.UTF-8'
flags = None

    def compose_table_new_from_locale(self, locale, flags=None):
        """Create a compose table for a given locale.

        The locale is used for searching the file-system for an
        appropriate Compose file. The search order is described in
        Compose(5). It is affected by the following environment
        variables:

        XCOMPOSEFILE - see Compose(5).

        XDG_CONFIG_HOME - before $HOME/.XCompose is checked,
        $XDG_CONFIG_HOME/XCompose is checked (with a fall back to
        $HOME/.config/XCompose if XDG_CONFIG_HOME is not
        defined). This is a libxkbcommon extension to the search
        procedure in Compose(5) (since libxkbcommon 1.0.0). Note that
        other implementations, such as libX11, might not find a
        Compose file in this path.

        HOME - see Compose(5).

        XLOCALEDIR - if set, used as the base directory for the
        system's X locale files, e.g. /usr/share/X11/locale, instead
        of the preconfigured directory.
        """
        c_locale = ffi.new("char[]", locale.encode())
        table = lib.xkb_compose_table_new_from_locale(
            self._context, c_locale, flags if flags else 0)
        if not table:
>           raise XKBComposeTableCreationFailure(
                f"Could not create compose table from locale '{locale}'")
E           xkbcommon.xkb.XKBComposeTableCreationFailure: Could not create compose table from locale 'en_GB.UTF-8'

xkbcommon/xkb.py:500: XKBComposeTableCreationFailure
----------------------------- Captured stderr call -----------------------------
xkbcommon: ERROR: couldn't find a Compose file for locale "en_GB.UTF-8" (mapped to "en_GB.UTF-8")
=========================== short test summary info ============================
FAILED tests/test_xkb.py::TestContext::test_compose_table_new_from_locale - x...
========================= 1 failed, 87 passed in 0.12s =========================

Is the use of en_GB.UTF-8 strictly necessary for that test? Would C.UTF-8 work too?

sde1000 commented 3 months ago

C.UTF-8 should work for this test. I'm happy to change it.

Do any of the other tests have problems in your build environment?

dvzrv commented 3 months ago

Ah! I just added libx11 to the check dependencies (it provides /usr/share/X11/locale) and set the environment variable XLOCALEDIR to it. That works also with the chosen locale!

dvzrv commented 3 months ago

I think this ticket can be closed without further action. Thank you for the fast response! :bow: