Skip to content

Commit b8d4199

Browse files
authored
Skip tests when numpy is not available (#193)
1 parent 2ca3c4e commit b8d4199

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

sdl2/test/sdl2ext_draw_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
from sdl2.ext.compat import ExperimentalWarning
77
from sdl2 import ext as sdl2ext
88

9+
try:
10+
import numpy
11+
_HASNUMPY = True
12+
except:
13+
_HASNUMPY = False
914

1015
class TestSDL2ExtDraw(object):
1116
__tags__ = ["sdl", "sdl2ext"]
@@ -21,6 +26,7 @@ def setup_class(cls):
2126
def teardown_class(cls):
2227
sdl2ext.quit()
2328

29+
@pytest.mark.skipif(not _HASNUMPY, reason="pixels3d requires numpy module")
2430
def test_fill(self):
2531
# Initialize colour and surface/view
2632
WHITE = (255, 255, 255)
@@ -63,6 +69,7 @@ def test_fill(self):
6369
with pytest.raises(ValueError):
6470
sdl2ext.fill(sf.contents, WHITE, (1, 2, 3))
6571

72+
@pytest.mark.skipif(not _HASNUMPY, reason="pixels3d requires numpy module")
6673
def test_line(self):
6774
# Initialize colour and surface/view
6875
WHITE = (255, 255, 255)

sdl2/test/sdl2ext_font_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22
import pytest
3-
import numpy as np
43
from sdl2 import ext as sdl2ext
54
from sdl2.ext.compat import byteify, ExperimentalWarning
65
from sdl2.ext.pixelaccess import pixels2d
@@ -46,7 +45,7 @@ def test_BitmapFont(self):
4645
# Try SDL_Surface surface
4746
font = sdl2ext.BitmapFont(sf.contents, (32, 32), FONTMAP)
4847
assert font.size == (32, 32)
49-
48+
5049
# Try SDL_Surface pointer surface
5150
font = sdl2ext.BitmapFont(sf, (32, 32), FONTMAP)
5251
assert font.size == (32, 32)
@@ -72,6 +71,7 @@ def test_BitmapFont_render(self):
7271
font.render("this_should_fail")
7372

7473
def test_BitmapFont_render_on(self):
74+
np = pytest.importorskip("numpy", reason="numpy module is not available")
7575
# Initialize font, surface, and BitmapFont for tests
7676
fontpath = byteify(RESOURCES.get_path("font.bmp"), "utf-8")
7777
sf = surface.SDL_LoadBMP(fontpath)

0 commit comments

Comments
 (0)