forked from pool/python-PySDL2
- Update to version 0.9.8 * This release fixes a number of bugs, updates the bindings to support new functions in SDL2 2.0.14, adds a wrapper for the SDL2 MessageBox API, and more. * Added bindings for new functions and constants introduced in SDL2 2.0.12 and 2.0.14 * Added full support for SDL2 binaries in non-system locations (e.g., with pysdl2-dll) when using PySDL2 with Python installed from the Microsoft Store on Windows. * Improved handling of SDL2 binaries that are too old to be used with PySDL2. * Added a new sdl2.ext API for displaying SDL2 MessageBox alerts and dialog boxes. - Add PySDL2-pr193-skipnumpy.patch (gh#marcusva/py-sdl2#193) for missing NumPy in python36 OBS-URL: https://build.opensuse.org/request/show/914878 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-PySDL2?expand=0&rev=13
71 lines
2.4 KiB
Diff
71 lines
2.4 KiB
Diff
From ebe6ca1b97a080c229ee80cfdd82d35663851f27 Mon Sep 17 00:00:00 2001
|
|
From: Ben Greiner <code@bnavigator.de>
|
|
Date: Sun, 29 Aug 2021 13:17:22 +0200
|
|
Subject: [PATCH] Skip tests when numpy is not available
|
|
|
|
---
|
|
sdl2/test/sdl2ext_draw_test.py | 7 +++++++
|
|
sdl2/test/sdl2ext_font_test.py | 4 ++--
|
|
2 files changed, 9 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/sdl2/test/sdl2ext_draw_test.py b/sdl2/test/sdl2ext_draw_test.py
|
|
index 63ff360..ac11bc8 100644
|
|
--- a/sdl2/test/sdl2ext_draw_test.py
|
|
+++ b/sdl2/test/sdl2ext_draw_test.py
|
|
@@ -6,6 +6,11 @@
|
|
from sdl2.ext.compat import ExperimentalWarning
|
|
from sdl2 import ext as sdl2ext
|
|
|
|
+try:
|
|
+ import numpy
|
|
+ _HASNUMPY = True
|
|
+except:
|
|
+ _HASNUMPY = False
|
|
|
|
class TestSDL2ExtDraw(object):
|
|
__tags__ = ["sdl", "sdl2ext"]
|
|
@@ -21,6 +26,7 @@ def setup_class(cls):
|
|
def teardown_class(cls):
|
|
sdl2ext.quit()
|
|
|
|
+ @pytest.mark.skipif(not _HASNUMPY, reason="pixels3d requires numpy module")
|
|
def test_fill(self):
|
|
# Initialize colour and surface/view
|
|
WHITE = (255, 255, 255)
|
|
@@ -63,6 +69,7 @@ def test_fill(self):
|
|
with pytest.raises(ValueError):
|
|
sdl2ext.fill(sf.contents, WHITE, (1, 2, 3))
|
|
|
|
+ @pytest.mark.skipif(not _HASNUMPY, reason="pixels3d requires numpy module")
|
|
def test_line(self):
|
|
# Initialize colour and surface/view
|
|
WHITE = (255, 255, 255)
|
|
diff --git a/sdl2/test/sdl2ext_font_test.py b/sdl2/test/sdl2ext_font_test.py
|
|
index 8ad8000..a9acde5 100644
|
|
--- a/sdl2/test/sdl2ext_font_test.py
|
|
+++ b/sdl2/test/sdl2ext_font_test.py
|
|
@@ -1,6 +1,5 @@
|
|
# -*- coding: utf-8 -*-
|
|
import pytest
|
|
-import numpy as np
|
|
from sdl2 import ext as sdl2ext
|
|
from sdl2.ext.compat import byteify, ExperimentalWarning
|
|
from sdl2.ext.pixelaccess import pixels2d
|
|
@@ -46,7 +45,7 @@ def test_BitmapFont(self):
|
|
# Try SDL_Surface surface
|
|
font = sdl2ext.BitmapFont(sf.contents, (32, 32), FONTMAP)
|
|
assert font.size == (32, 32)
|
|
-
|
|
+
|
|
# Try SDL_Surface pointer surface
|
|
font = sdl2ext.BitmapFont(sf, (32, 32), FONTMAP)
|
|
assert font.size == (32, 32)
|
|
@@ -72,6 +71,7 @@ def test_BitmapFont_render(self):
|
|
font.render("this_should_fail")
|
|
|
|
def test_BitmapFont_render_on(self):
|
|
+ np = pytest.importorskip("numpy", reason="numpy module is not available")
|
|
# Initialize font, surface, and BitmapFont for tests
|
|
fontpath = byteify(RESOURCES.get_path("font.bmp"), "utf-8")
|
|
sf = surface.SDL_LoadBMP(fontpath)
|