Skip to content

Commit

Permalink
video_test: Use _check_error_msg() a bit more often
Browse files Browse the repository at this point in the history
Signed-off-by: Simon McVittie <[email protected]>
  • Loading branch information
smcv committed Aug 19, 2023
1 parent e38c4ab commit fd67df5
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions sdl2/test/video_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def with_sdl_gl(with_sdl):
def window(with_sdl):
flag = sdl2.SDL_WINDOW_BORDERLESS
w = sdl2.SDL_CreateWindow(b"Test", 10, 40, 12, 13, flag)
if not w:
assert SDL_GetError() == b""
assert w, _check_error_msg()
assert isinstance(w.contents, sdl2.SDL_Window)
sdl2.SDL_ClearError()
yield w
Expand All @@ -63,8 +62,7 @@ def window(with_sdl):
def decorated_window(with_sdl):
flag = sdl2.SDL_WINDOW_RESIZABLE
w = sdl2.SDL_CreateWindow(b"Test", 10, 40, 12, 13, flag)
if not w:
assert SDL_GetError() == b""
assert w, _check_error_msg()
assert isinstance(w.contents, sdl2.SDL_Window)
sdl2.SDL_ClearError()
yield w
Expand All @@ -74,8 +72,7 @@ def decorated_window(with_sdl):
def gl_window(with_sdl_gl):
flag = sdl2.SDL_WINDOW_OPENGL
w = sdl2.SDL_CreateWindow(b"OpenGL", 10, 40, 12, 13, flag)
if not w:
assert SDL_GetError() == b""
assert w, _check_error_msg()
assert isinstance(w.contents, sdl2.SDL_Window)
sdl2.SDL_ClearError()
ctx = sdl2.SDL_GL_CreateContext(w)
Expand Down Expand Up @@ -192,7 +189,7 @@ def test_SDL_VideoInitQuit():
# Test with default driver
assert sdl2.SDL_WasInit(0) & sdl2.SDL_INIT_VIDEO != sdl2.SDL_INIT_VIDEO
ret = sdl2.SDL_VideoInit(None)
assert ret == 0, sdl2.SDL_GetError().decode('utf-8', 'replace')
assert ret == 0, _check_error_msg()
assert sdl2.SDL_GetCurrentVideoDriver() # If initialized, should be string
sdl2.SDL_VideoQuit()
assert not sdl2.SDL_GetCurrentVideoDriver()
Expand Down

0 comments on commit fd67df5

Please sign in to comment.