Skip to content

Commit d4210dc

Browse files
committed
Try fixing test failures with Conda's binaries
1 parent 5dfebf0 commit d4210dc

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

sdl2/test/sdl2ext_image_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def test_save_bmp(self, tmpdir):
141141
sdl2ext.save_bmp(sf_saved, bad_path)
142142

143143

144+
@pytest.mark.skipif(not _HASSDLIMAGE, reason="Requires SDL2_image")
144145
def test_load_img(self):
145146
# Test loading all test images, with and without ARGB conversion
146147
resources = os.listdir(resource_path)
@@ -222,7 +223,7 @@ def test_pillow_to_image(self):
222223
self.check_image_contents(sf)
223224
surf.SDL_FreeSurface(sf)
224225

225-
226+
@pytest.mark.skipif(not _HASSDLIMAGE, reason="Requires SDL2_image")
226227
def test_load_image(self):
227228
resources = os.listdir(resource_path)
228229
test_imgs = [f for f in resources if f[:11] == "surfacetest"]

sdl2/test/sdlimage_test.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
is32bit = sys.maxsize <= 2**32
1313
ismacos = sys.platform == "darwin"
14+
iswindows = "win" in sys.platform
15+
isconda = os.getenv("CONDA_PREFIX") != None
1416

1517
formats = ["bmp",
1618
"cur",
@@ -33,14 +35,18 @@
3335
#"xv",
3436
]
3537

36-
# SVG unsupported on SDL2_image < 2.0.2
37-
if sdlimage.dll.version < 2002:
38+
# SVG unsupported on SDL2_image < 2.0.2 as well as in Conda's current (2.0.5)
39+
# Windows binaries
40+
if sdlimage.dll.version < 2002 or (isconda and iswindows):
3841
formats.remove("svg")
3942

4043
# As of SDL2_image 2.0.5, XCF support seems to be broken on 32-bit builds
41-
# XCF support is also broken in official SDL2_image macOS .frameworks
42-
if is32bit or ismacos:
44+
# XCF support is also broken in official SDL2_image macOS .frameworks and
45+
# Conda's SDL2_image Windows binaries
46+
bad_xcf = False
47+
if is32bit or ismacos or (isconda and iswindows):
4348
formats.remove("xcf")
49+
bad_xcf = True
4450

4551
# WEBP support seems to be broken in the 32-bit Windows SDL2_image 2.0.2 binary
4652
bad_webp = is32bit and sdlimage.dll.version == 2002
@@ -254,6 +260,7 @@ def test_IMG_LoadPNM_RW(self):
254260
surface.SDL_FreeSurface(sf)
255261

256262
@pytest.mark.skipif(sdlimage.dll.version < 2002, reason="Added in 2.0.2")
263+
@pytest.mark.xfail(isconda and iswindows, reason="Broken w/ win64 Conda")
257264
def test_IMG_LoadSVG_RW(self):
258265
fp = open(_get_image_path("svg"), "rb")
259266
sf = sdlimage.IMG_LoadSVG_RW(rwops.rw_from_object(fp))
@@ -283,7 +290,7 @@ def test_IMG_LoadWEBP_RW(self):
283290
assert isinstance(sf.contents, surface.SDL_Surface)
284291
surface.SDL_FreeSurface(sf)
285292

286-
@pytest.mark.xfail(is32bit or ismacos, reason="XCF currently broken on 32-bit and macOS")
293+
@pytest.mark.xfail(bad_xcf, reason="XCF currently broken on some platforms")
287294
def test_IMG_LoadXCF_RW(self):
288295
fp = open(_get_image_path("xcf"), "rb")
289296
sf = sdlimage.IMG_LoadXCF_RW(rwops.rw_from_object(fp))
@@ -397,6 +404,7 @@ def test_IMG_isPNM(self):
397404
assert not sdlimage.IMG_isPNM(imgrw)
398405

399406
@pytest.mark.skipif(sdlimage.dll.version < 2002, reason="Added in 2.0.2")
407+
@pytest.mark.xfail(isconda and iswindows, reason="Broken w/ win64 Conda")
400408
def test_IMG_isSVG(self):
401409
for fmt in formats:
402410
fpath = _get_image_path(fmt)
@@ -427,7 +435,7 @@ def test_IMG_isWEBP(self):
427435
else:
428436
assert not sdlimage.IMG_isWEBP(imgrw)
429437

430-
@pytest.mark.xfail(ismacos, reason="XCF currently broken on macOS")
438+
@pytest.mark.xfail(bad_xcf, reason="XCF currently broken on some platforms")
431439
def test_IMG_isXCF(self):
432440
for fmt in formats:
433441
fpath = _get_image_path(fmt)

sdl2/test/version_test.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ def test_SDL_VERSION_ATLEAST(self):
3434
assert not version.SDL_VERSION_ATLEAST(2, 0, 100)
3535

3636
def test_SDL_GetRevision(self):
37-
if dll.version >= 2016:
38-
assert version.SDL_GetRevision()[0:4] == b"http"
39-
else:
40-
assert version.SDL_GetRevision()[0:3] == b"hg-"
37+
rev = version.SDL_GetRevision()
38+
# If revision not empty string (e.g. Conda), test the prefix
39+
if len(rev):
40+
if dll.version >= 2016:
41+
assert rev[0:4] == b"http"
42+
else:
43+
assert rev[0:3] == b"hg-"
4144

4245
def test_SDL_GetRevisionNumber(self):
4346
if sys.platform in ("win32",) or dll.version >= 2016:

0 commit comments

Comments
 (0)