From d7c0604381f6cbefa2c8b51c84b879e2f927e91e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 19 Aug 2023 23:38:36 +0100 Subject: [PATCH] test: Don't assert that SDL_hid_enumerate doesn't set error (#269) On my Linux system, enumeration succeeds, but the error indicator gets set as a side-effect (which appears to be because the loader checks whether the symbol exists in SDL or a direct dependency before it dlopens libudev). The API of SDL_hid_enumerate does not make it possible to distinguish between successfully returning an empty list of devices (returns NULL with the error indicator in an undefined state) and a failure (returns NULL with the error indicator set), and systems that run automated tests usually don't have any HID game controllers connected, so we can't make any meaningful use of the error indicator here. Helps: https://github.com/py-sdl/py-sdl2/issues/257 Signed-off-by: Simon McVittie --- sdl2/test/hidapi_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdl2/test/hidapi_test.py b/sdl2/test/hidapi_test.py index 68bb9f9..5422d42 100644 --- a/sdl2/test/hidapi_test.py +++ b/sdl2/test/hidapi_test.py @@ -38,10 +38,11 @@ def test_SDL_hid_device_change_count(hidapi_setup): def test_SDL_hid_enumerate(hidapi_setup): devices = sdl2.SDL_hid_enumerate(0, 0) - assert SDL_GetError() == b"" + # Cannot check the error indicator here: a non-error empty list is + # indistinguishable from an error, and it is not guaranteed that the + # error indicator will not be set as a side-effect of a successful load if devices != None: sdl2.SDL_hid_free_enumeration(devices) - assert SDL_GetError() == b"" @pytest.mark.skip("not implemented")