forked from pool/python-PySDL2
Accepting request 1104930 from home:munix9:branches:devel:languages:python
- Remove fix-tests.patch in favor of upstream patches - Add upstream patches to resolve test failures: fix-partially-resolve-video_test.patch fix-test-SDL_hid_enumerate.patch fix-tests-SDL_GetError.patch OBS-URL: https://build.opensuse.org/request/show/1104930 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-PySDL2?expand=0&rev=29
This commit is contained in:
148
fix-tests-SDL_GetError.patch
Normal file
148
fix-tests-SDL_GetError.patch
Normal file
@@ -0,0 +1,148 @@
|
||||
From 1c865e3f751e678f3ad2d8f3fca17a0755fbeaf7 Mon Sep 17 00:00:00 2001
|
||||
From: basak <robie@justgohome.co.uk>
|
||||
Date: Fri, 11 Aug 2023 17:52:01 +0100
|
||||
Subject: [PATCH] tests: SDL_GetError() != b'' isn't an error (#267)
|
||||
|
||||
* tests: SDL_GetError() != b'' isn't an error
|
||||
|
||||
In Ubuntu, we're seeing test failures of the following pattern when
|
||||
moving from libsdl2 2.28.1+dfsg-1 to 2.28.2+dfsg-1:
|
||||
|
||||
> assert sdl2.SDL_GetError() == b""
|
||||
E AssertionError: assert b'Unexpected ...r element crc' == b''
|
||||
E Full diff:
|
||||
E - b''
|
||||
E + b'Unexpected controller element crc'
|
||||
|
||||
This looks like an issue similar to that fixed in commit 8c39f40. We
|
||||
should check the relevant return value, and only if it indicates failure
|
||||
should we attach any particular meaning to the return value of
|
||||
SDL_GetError().
|
||||
|
||||
* Add myself to AUTHORS.txt
|
||||
|
||||
As instructed in #267
|
||||
---
|
||||
AUTHORS.txt | 1 +
|
||||
sdl2/test/gamecontroller_test.py | 16 +++-------------
|
||||
2 files changed, 4 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/AUTHORS.txt b/AUTHORS.txt
|
||||
index 287109e..6d40500 100644
|
||||
--- a/AUTHORS.txt
|
||||
+++ b/AUTHORS.txt
|
||||
@@ -45,6 +45,7 @@ Thanks to everyone else for their assistance, support, fixes and improvements:
|
||||
* Radomir Dopieralski
|
||||
* Rob Rolls
|
||||
* Robert Winkler
|
||||
+* Robie Basak
|
||||
* Roger Flores
|
||||
* Simon McVittie
|
||||
* smea lum
|
||||
diff --git a/sdl2/test/gamecontroller_test.py b/sdl2/test/gamecontroller_test.py
|
||||
index 7a00aac..f509a88 100644
|
||||
--- a/sdl2/test/gamecontroller_test.py
|
||||
+++ b/sdl2/test/gamecontroller_test.py
|
||||
@@ -51,7 +51,7 @@ def gamepads(with_sdl):
|
||||
for i in range(count):
|
||||
if sdl2.SDL_IsGameController(i) == SDL_TRUE:
|
||||
pad = sdl2.SDL_GameControllerOpen(i)
|
||||
- assert sdl2.SDL_GetError() == b""
|
||||
+ assert pad, _check_error_msg()
|
||||
assert isinstance(pad.contents, sdl2.SDL_GameController)
|
||||
devices.append(pad)
|
||||
yield devices
|
||||
@@ -133,21 +133,18 @@ def test_SDL_GameControllerMappingForGUID(with_sdl):
|
||||
def test_SDL_GameControllerMapping(gamepads):
|
||||
for pad in gamepads:
|
||||
mapping = sdl2.SDL_GameControllerMapping(pad)
|
||||
- assert SDL_GetError() == b""
|
||||
assert mapping == None or type(mapping) in (str, bytes)
|
||||
|
||||
def test_SDL_IsGameController(with_sdl):
|
||||
count = joystick.SDL_NumJoysticks()
|
||||
for index in range(count):
|
||||
ret = sdl2.SDL_IsGameController(index)
|
||||
- assert sdl2.SDL_GetError() == b""
|
||||
assert ret in [SDL_TRUE, SDL_FALSE]
|
||||
|
||||
def test_SDL_GameControllerNameForIndex(with_sdl):
|
||||
count = joystick.SDL_NumJoysticks()
|
||||
for index in range(count):
|
||||
name = sdl2.SDL_GameControllerNameForIndex(index)
|
||||
- assert sdl2.SDL_GetError() == b""
|
||||
assert name == None or type(name) in (str, bytes)
|
||||
|
||||
@pytest.mark.skipif(sdl2.dll.version < 2231, reason="not available")
|
||||
@@ -174,7 +171,7 @@ def test_SDL_GameControllerOpenClose(with_sdl):
|
||||
for index in range(count):
|
||||
if sdl2.SDL_IsGameController(index) == SDL_TRUE:
|
||||
pad = sdl2.SDL_GameControllerOpen(index)
|
||||
- assert sdl2.SDL_GetError() == b""
|
||||
+ assert pad, _check_error_msg()
|
||||
assert isinstance(pad.contents, sdl2.SDL_GameController)
|
||||
sdl2.SDL_GameControllerClose(pad)
|
||||
|
||||
@@ -220,7 +217,6 @@ def test_SDL_GameControllerPath(gamepads):
|
||||
def test_SDL_GameControllerGetType(gamepads):
|
||||
for pad in gamepads:
|
||||
padtype = sdl2.SDL_GameControllerGetType(pad)
|
||||
- assert SDL_GetError() == b""
|
||||
assert padtype in gamepad_types
|
||||
if is_virtual(pad):
|
||||
assert padtype == sdl2.SDL_CONTROLLER_TYPE_VIRTUAL
|
||||
@@ -244,7 +240,6 @@ def test_SDL_GameControllerSetPlayerIndex(gamepads):
|
||||
def test_SDL_GameControllerGetVendor(gamepads):
|
||||
for pad in gamepads:
|
||||
vid = sdl2.SDL_GameControllerGetVendor(pad)
|
||||
- assert SDL_GetError() == b""
|
||||
if not is_virtual(pad):
|
||||
assert vid > 0
|
||||
|
||||
@@ -252,7 +247,6 @@ def test_SDL_GameControllerGetVendor(gamepads):
|
||||
def test_SDL_GameControllerGetProduct(gamepads):
|
||||
for pad in gamepads:
|
||||
pid = sdl2.SDL_GameControllerGetProduct(pad)
|
||||
- assert SDL_GetError() == b""
|
||||
if not is_virtual(pad):
|
||||
assert pid > 0
|
||||
|
||||
@@ -260,21 +254,18 @@ def test_SDL_GameControllerGetProduct(gamepads):
|
||||
def test_SDL_GameControllerGetProductVersion(gamepads):
|
||||
for pad in gamepads:
|
||||
pver = sdl2.SDL_GameControllerGetProductVersion(pad)
|
||||
- assert SDL_GetError() == b""
|
||||
assert pver >= 0
|
||||
|
||||
@pytest.mark.skipif(sdl2.dll.version < 2231, reason="not available")
|
||||
def test_SDL_GameControllerGetFirmwareVersion(gamepads):
|
||||
for pad in gamepads:
|
||||
fw_ver = sdl2.SDL_GameControllerGetFirmwareVersion(pad)
|
||||
- assert SDL_GetError() == b""
|
||||
assert fw_ver >= 0
|
||||
|
||||
@pytest.mark.skipif(sdl2.dll.version < 2014, reason="not available")
|
||||
def test_SDL_GameControllerGetSerial(gamepads):
|
||||
for pad in gamepads:
|
||||
serial = sdl2.SDL_GameControllerGetSerial(pad)
|
||||
- assert SDL_GetError() == b""
|
||||
assert serial == None or type(serial) in (str, bytes)
|
||||
|
||||
def test_SDL_GameControllerGetAttached(gamepads):
|
||||
@@ -285,7 +276,7 @@ def test_SDL_GameControllerGetAttached(gamepads):
|
||||
def test_SDL_GameControllerGetJoystick(gamepads):
|
||||
for pad in gamepads:
|
||||
stick = sdl2.SDL_GameControllerGetJoystick(pad)
|
||||
- assert SDL_GetError() == b""
|
||||
+ assert stick, _check_error_msg()
|
||||
assert isinstance(stick.contents, joystick.SDL_Joystick)
|
||||
|
||||
def test_SDL_GameControllerEventState(with_sdl):
|
||||
@@ -298,7 +289,6 @@ def test_SDL_GameControllerEventState(with_sdl):
|
||||
def test_SDL_GameControllerUpdate(with_sdl):
|
||||
# NOTE: Returns void, can't really test anything else
|
||||
sdl2.SDL_GameControllerUpdate()
|
||||
- assert SDL_GetError() == b""
|
||||
|
||||
def test_SDL_GameControllerGetAxisFromString(with_sdl):
|
||||
expected = {
|
Reference in New Issue
Block a user