Commits

Marcus von Appen  committed 27d26bb

- fake the SDLmain invocation for Win32 - it is required now
- fixed bytes/str write issue for tests being executed as subprocesses

  • Participants
  • Parent commits d4e63dd

Comments (0)

Files changed (3)

File sdl2/__init__.py

 from .keycode import *
 from .scancode import *
 
+# At least Win32 platforms need this now.
+_SDL_SetMainReady = _bind("SDL_SetMainReady")
+_SDL_SetMainReady()
+
+
 SDL_INIT_TIMER = 0x00000001
 SDL_INIT_AUDIO = 0x00000010
 SDL_INIT_VIDEO = 0x00000020

File sdl2/test/sdl_test.py

 from .. import SDL_Init, SDL_WasInit, SDL_InitSubSystem, SDL_QuitSubSystem, \
     SDL_Quit, SDL_INIT_AUDIO, SDL_INIT_EVERYTHING, SDL_INIT_GAMECONTROLLER, \
     SDL_INIT_HAPTIC, SDL_INIT_JOYSTICK, SDL_INIT_NOPARACHUTE, SDL_INIT_TIMER, \
-    SDL_INIT_VIDEO
+    SDL_INIT_VIDEO, SDL_GetError
 
 
 class SDLTest(unittest.TestCase):
         SDL_Quit()
 
     def test_SDL_INIT_TIMER(self):
-        SDL_Init(SDL_INIT_TIMER)
+        ret = SDL_Init(SDL_INIT_TIMER)
+        self.assertEqual(ret, 0, SDL_GetError())
         ret = SDL_WasInit(SDL_INIT_TIMER)
         self.assertEqual(ret, SDL_INIT_TIMER)
         SDL_QuitSubSystem(SDL_INIT_TIMER)
 
     def test_SDL_INIT_AUDIO(self):
-        SDL_Init(SDL_INIT_AUDIO)
+        ret = SDL_Init(SDL_INIT_AUDIO)
+        self.assertEqual(ret, 0, SDL_GetError())
         ret = SDL_WasInit(SDL_INIT_AUDIO)
         self.assertEqual(ret, SDL_INIT_AUDIO)
         SDL_QuitSubSystem(SDL_INIT_AUDIO)
 
     def test_SDL_INIT_VIDEO(self):
-        SDL_Init(SDL_INIT_VIDEO)
+        ret = SDL_Init(SDL_INIT_VIDEO)
+        self.assertEqual(ret, 0, SDL_GetError())
         ret = SDL_WasInit(SDL_INIT_VIDEO)
         self.assertEqual(ret, SDL_INIT_VIDEO)
         SDL_QuitSubSystem(SDL_INIT_VIDEO)
 
     def test_SDL_INIT_JOYSTICK(self):
-        SDL_Init(SDL_INIT_JOYSTICK)
+        ret = SDL_Init(SDL_INIT_JOYSTICK)
+        self.assertEqual(ret, 0, SDL_GetError())
         ret = SDL_WasInit(SDL_INIT_JOYSTICK)
         self.assertEqual(ret, SDL_INIT_JOYSTICK)
         SDL_QuitSubSystem(SDL_INIT_JOYSTICK)
 
     def test_SDL_INIT_HAPTIC(self):
-        SDL_Init(SDL_INIT_HAPTIC)
+        ret = SDL_Init(SDL_INIT_HAPTIC)
+        self.assertEqual(ret, 0, SDL_GetError())
         ret = SDL_WasInit(SDL_INIT_HAPTIC)
         if sys.platform.startswith("freebsd"):
             # not supported yet

File sdl2/test/util/runtests.py

                 writer.writeline("execution timed out")
             elif retval != 0:
                 writer.writeline("ERROR")
-                writer.write(proc.stdout.read())
+                writer.write(proc.stdout.read().decode("utf-8"))
                 writer.writeline()
             else:
                 writer.writeline("OK")
                 if options.verbose:
-                    writer.write(proc.stdout.read())
+                    writer.write(proc.stdout.read().decode("utf-8"))
                     writer.writeline()
         return 0