From ebf70fbc7a70cbef10e87eaaaec3907fa94599237ec0c751d1adf8039b43ae46 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 1 Aug 2022 15:07:48 +0000 Subject: [PATCH] - Add mixer_tests_fix.patch to switch off failing tests (gh#py-sdl/py-sdl2#241). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-PySDL2?expand=0&rev=17 --- mixer_tests_fix.patch | 73 +++++++++++++++++++++++++++++++++++++++++++ python-PySDL2.changes | 3 +- python-PySDL2.spec | 12 ++++--- 3 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 mixer_tests_fix.patch diff --git a/mixer_tests_fix.patch b/mixer_tests_fix.patch new file mode 100644 index 0000000..2412b07 --- /dev/null +++ b/mixer_tests_fix.patch @@ -0,0 +1,73 @@ +diff --git a/sdl2/test/sdlmixer_test.py b/sdl2/test/sdlmixer_test.py +index 8d2db3e..dd50004 100644 +--- a/sdl2/test/sdlmixer_test.py ++++ b/sdl2/test/sdlmixer_test.py +@@ -19,6 +19,14 @@ def _get_sound_path(fmt): + testdir = os.path.dirname(os.path.abspath(__file__)) + return os.path.join(testdir, "resources", fname) + ++def _has_decoder(decoder): ++ decoders = [] ++ num = sdlmixer.Mix_GetNumChunkDecoders() ++ for i in range(0, num): ++ name = sdlmixer.Mix_GetChunkDecoder(i) ++ decoders.append(name.decode('utf-8')) ++ return decoder.upper() in decoders ++ + @pytest.fixture(scope="module") + def with_sdl_mixer(): + # Initialize SDL2 with video and audio subsystems +@@ -41,6 +49,8 @@ def with_sdl_mixer(): + + @pytest.fixture + def with_mixchunk(with_sdl_mixer): ++ if not _has_decoder("mp3"): ++ pytest.skip("No MP3 decoder available for SDL_mixer") + fpath = _get_sound_path("mp3") + chk = sdlmixer.Mix_LoadWAV(fpath.encode("utf-8")) + err = sdlmixer.Mix_GetError() +@@ -51,6 +61,8 @@ def with_mixchunk(with_sdl_mixer): + + @pytest.fixture + def with_music(with_sdl_mixer): ++ if not _has_decoder("mp3"): ++ pytest.skip("No MP3 decoder available for SDL_mixer") + fpath = _get_sound_path("mp3") + mus = sdlmixer.Mix_LoadMUS(fpath.encode("utf-8")) + err = sdlmixer.Mix_GetError() +@@ -140,6 +152,8 @@ def test_Mix_QuerySpec(with_sdl_mixer): + assert fmt.value in audio.AUDIO_FORMATS + + def test_Mix_LoadFreeWAV(with_sdl_mixer): ++ if not _has_decoder("mp3"): ++ pytest.skip("No MP3 decoder available for SDL_mixer") + fpath = _get_sound_path("mp3") + chk = sdlmixer.Mix_LoadWAV(fpath.encode("utf-8")) + assert isinstance(chk.contents, sdlmixer.Mix_Chunk) +@@ -147,6 +161,8 @@ def test_Mix_LoadFreeWAV(with_sdl_mixer): + sdlmixer.Mix_FreeChunk(chk) + + def test_Mix_LoadWAV_RW(with_sdl_mixer): ++ if not _has_decoder("mp3"): ++ pytest.skip("No MP3 decoder available for SDL_mixer") + fpath = _get_sound_path("mp3") + rw = sdl2.SDL_RWFromFile(fpath.encode("utf-8"), b"r") + chk = sdlmixer.Mix_LoadWAV_RW(rw, 1) +@@ -155,6 +171,8 @@ def test_Mix_LoadWAV_RW(with_sdl_mixer): + sdlmixer.Mix_FreeChunk(chk) + + def test_Mix_LoadFreeMUS(with_sdl_mixer): ++ if not _has_decoder("mp3"): ++ pytest.skip("No MP3 decoder available for SDL_mixer") + fpath = _get_sound_path("mp3") + mus = sdlmixer.Mix_LoadMUS(fpath.encode("utf-8")) + assert isinstance(mus.contents, sdlmixer.Mix_Music) +@@ -162,6 +180,8 @@ def test_Mix_LoadFreeMUS(with_sdl_mixer): + sdlmixer.Mix_FreeMusic(mus) + + def test_Mix_LoadMUS_RW(with_sdl_mixer): ++ if not _has_decoder("mp3"): ++ pytest.skip("No MP3 decoder available for SDL_mixer") + fpath = _get_sound_path("mp3") + rw = sdl2.SDL_RWFromFile(fpath.encode("utf-8"), b"r") + mus = sdlmixer.Mix_LoadMUS_RW(rw, 1) diff --git a/python-PySDL2.changes b/python-PySDL2.changes index 5faef37..f7f10bb 100644 --- a/python-PySDL2.changes +++ b/python-PySDL2.changes @@ -18,7 +18,8 @@ Fri Jul 29 12:38:06 UTC 2022 - Matej Cepl - Added a stable API for accessing the raw ctypes function objects for SDL2 functions - Various bugfixes (see the project's news.rst for more info) -- Switch off failing tests (gh#py-sdl/py-sdl2#241) +- Add mixer_tests_fix.patch to switch off failing tests + (gh#py-sdl/py-sdl2#241). ------------------------------------------------------------------- Sun Mar 20 09:55:17 UTC 2022 - Ben Greiner diff --git a/python-PySDL2.spec b/python-PySDL2.spec index 91c9f39..347a2fc 100644 --- a/python-PySDL2.spec +++ b/python-PySDL2.spec @@ -25,7 +25,12 @@ Summary: Python ctypes wrapper around SDL2 License: SUSE-Public-Domain URL: https://github.com/py-sdl/py-sdl2 Source: https://files.pythonhosted.org/packages/source/P/PySDL2/PySDL2-%{version}.tar.gz +# PATCH-FIX-UPSTREAM mixer_tests_fix.patch gh#py-sdl/py-sdl2#241 mcepl@suse.com +# allow dynamic configuration of libmpg123 +Patch0: mixer_tests_fix.patch +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} BuildRequires: SDL2 >= 2.0.22 BuildRequires: SDL2_gfx >= 1.0.4 BuildRequires: SDL2_image >= 2.6.0 @@ -55,13 +60,14 @@ Python classes and wrappers for common SDL2 functionality. %prep %autosetup -p1 -n PySDL2-%{version} + sed -i 's/\r$//' AUTHORS.txt COPYING.txt README.md %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check @@ -94,8 +100,6 @@ donttest="$donttest or test_SDL_GetPowerInfo" # python2 env different, pytest arg missing python2_donttest=" or test_SDL_GetBasePath or test_render_on" %endif -# gh#py-sdl/py-sdl2#241 -donttest="$donttest or sdlmixer_test" %pytest -rfEs -k "not ($donttest ${$python_donttest})" %files %{python_files}