Marcus von Appen avatar Marcus von Appen committed b417daa

- fixed several unittests on Win32
- fixed several unittests for Python 3.x
- fixed DLL path handling for SDL_ttf and freetype loading on Win32

Comments (0)

Files changed (23)

     platform = sys.platform
     if platform in ("win32", "cli"):
         suffix = ".dll"
+        if path:
+            os.environ["PATH"] += ";%s" % path
     elif platform == "darwin":
         suffix = ".dylib"
     else:
 Uint64 = c_uint64
 
 _libc = None
-if sys.platform == "win32":
+if sys.platform in ("win32", "cli"):
     _libc = cdll.msvcrt
 else:
     _libc = cdll.LoadLibrary("libc.so")

sdl2/test/clipboard_test.py

 
     @unittest.skipIf(not is_win_or_mac(), "we would need a SDL window")
     def test_SDL_SetClipboardText(self):
-        self.assertEquals(clipboard.SDL_SetClipboardText("Test content"), 0)
+        self.assertEquals(clipboard.SDL_SetClipboardText(b"Test content"), 0)
         retval = clipboard.SDL_GetClipboardText()
-        self.assertEqual(retval, "Test content")
+        self.assertEqual(retval, b"Test content")
 
-        self.assertEquals(clipboard.SDL_SetClipboardText(""), 0)
+        self.assertEquals(clipboard.SDL_SetClipboardText(b""), 0)
         retval = clipboard.SDL_GetClipboardText()
-        self.assertEqual(retval, "")
+        self.assertEqual(retval, b"")
 
-        self.assertEquals(clipboard.SDL_SetClipboardText("Test content"), 0)
+        self.assertEquals(clipboard.SDL_SetClipboardText(b"Test content"), 0)
         retval = clipboard.SDL_GetClipboardText()
-        self.assertEqual(retval, "Test content")
+        self.assertEqual(retval, b"Test content")
 
         self.assertEquals(clipboard.SDL_SetClipboardText(None), 0)
         retval = clipboard.SDL_GetClipboardText()
-        self.assertEqual(retval, str(None))
+        self.assertEqual(retval, b"")
 
 if __name__ == '__main__':
     sys.exit(unittest.main())
Add a comment to this file

sdl2/test/resources/surfacetest.lbm

Binary file added.

sdl2/test/sdl2ext_algorithms_test.py

 from ..ext import algorithms
 
 
-class AlgorithmsTest(unittest.TestCase):
+class SDL2ExtAlgorithmsTest(unittest.TestCase):
+    __tags__ = ["sdl2ext"]
 
     @unittest.skip("not implemented")
     def test_cohensutherland(self):
     @unittest.skip("not implemented")
     def test_liangbarsky(self):
         pass
-    
+
     @unittest.skip("not implemented")
     def test_clipline(self):
         pass

sdl2/test/sdl2ext_array_test.py

             raise IndexError("invalid position")
 
 
-class ArrayTest(unittest.TestCase):
-
-    def setUp(self):
-        if sys.version.startswith("3.1"):
-            self.assertIsInstance = \
-                lambda x, t: self.assertTrue(isinstance(x, t))
-
-    def tearDown(self):
-        pass
+class SDL2ExtArrayTest(unittest.TestCase):
+    __tags__ = ["sdl2ext"]
 
     def test_to_ctypes(self):
         for seq, dtype in ((singlebyteseq, ctypes.c_ubyte),

sdl2/test/sdl2ext_color_test.py

     x[p] = y
 
 
-class ColorTest(unittest.TestCase):
+class SDL2ExtColorTest(unittest.TestCase):
+    __tags__ = ["sdl2ext"]
 
     def test_Color(self):
         c = color.Color(10, 20, 30, 40)

sdl2/test/sdl2ext_draw_test.py

 from .. import ext as sdl2ext
 
 
-class VideoDrawTest(unittest.TestCase):
-    __tags__ = ["sdl"]
+class SDL2ExtDrawTest(unittest.TestCase):
+    __tags__ = ["sdl", "sdl2ext"]
 
     def setUp(self):
         sdl2ext.init()

sdl2/test/sdl2ext_ebs_test.py

             p.y += m.vy
 
 
-class EBSTest(unittest.TestCase):
-    __tags__ = ["ebs"]
-
-    def setUp(self):
-        if sys.version.startswith("3.1"):
-            self.assertIsInstance = \
-                lambda x, t: self.assertTrue(isinstance(x, t))
-
-    def tearDown(self):
-        pass
+class SDL2ExtEBSTest(unittest.TestCase):
+    __tags__ = ["ebs", "sdl2ext"]
 
     def test_Entity(self):
         world = World()

sdl2/test/sdl2ext_events_test.py

     # Does nothing
     pass
 
-class EventsTest(unittest.TestCase):
-
-    def setUp(self):
-        if sys.version.startswith("3.1"):
-            self.assertIsInstance = \
-                lambda x, t: self.assertTrue(isinstance(x, t))
-
-    def tearDown(self):
-        pass
+class SDL2ExtEventsTest(unittest.TestCase):
+    __tags__ = ["sdl2ext"]
 
     def test_EventHandler(self):
         self.assertRaises(TypeError, events.EventHandler)

sdl2/test/sdl2ext_font_test.py

            ]
 
 
-class VideoFontTest(unittest.TestCase):
-    __tags__ = ["sdl"]
+class SDL2ExtFontTest(unittest.TestCase):
+    __tags__ = ["sdl", "sdl2ext"]
 
     def setUp(self):
         sdl2ext.init()

sdl2/test/sdl2ext_gui_test.py

 from .. import ext as sdl2ext
 
 
-class VideoGUITest(unittest.TestCase):
-    __tags__ = ["sdl"]
+class SDL2ExtGUITest(unittest.TestCase):
+    __tags__ = ["sdl", "sdl2ext"]
 
     def setUp(self):
         sdl2ext.init()

sdl2/test/sdl2ext_image_test.py

 
 RESOURCES = sdl2ext.Resources(__file__, "resources")
 
-formats = (#"bmp",  # Do not use bmp - it's contained in resources.zip
+formats = [  #"bmp",  # Do not use bmp - it's contained in resources.zip
            "cur",
            "gif",
            "ico",
            "jpg",
-           # "lbm",
+           "lbm",
            "pbm",
            "pcx",
            "pgm",
            "tga",
            "tif",
            "webp",
-           "xcf",
+           #"xcf",
            "xpm",
            # "xv",
-           )
+           ]
 
+if sys.version_info[:2] == (3, 3) and sys.platform in ("win32", "cli"):
+    # TODO: fix this - lbm and pbm crash Python 3.3 on Win32 - maybe an
+    # issue in SDL2_image?
+    formats.remove("lbm")
+    formats.remove("pbm")
 
-class VideoImageTest(unittest.TestCase):
-    __tags__ = ["sdl"]
+class SDL2ExtImageTest(unittest.TestCase):
+    __tags__ = ["sdl", "sdl2ext"]
 
     def setUp(self):
         sdl2ext.init()
             self.assertIsInstance(sf, surface.SDL_Surface)
 
             # Force only PIL
-            if _HASPIL and fmt not in ("webp", "xcf"):
+            if _HASPIL and fmt not in ("webp", "xcf", "lbm"):
                 sf = sdl2ext.load_image(filename, enforce="PIL")
                 self.assertIsInstance(sf, surface.SDL_Surface)
 

sdl2/test/sdl2ext_particles_test.py

 from ..ext import particles
 
 
-class ParticlesTest(unittest.TestCase):
-
+class SDL2ExtParticlesTest(unittest.TestCase):
+    __tags__ = ["sdl2ext"]
 
     def test_Particle(self):
         p = particles.Particle(0, 0, 0)

sdl2/test/sdl2ext_pixelaccess_test.py

 except:
     _HASNUMPY = False
 
-class VideoPixelAccessTest(unittest.TestCase):
-    __tags__ = ["sdl"]
+class SDL2ExtPixelAccessTest(unittest.TestCase):
+    __tags__ = ["sdl", "sdl2ext"]
 
     def setUp(self):
         sdl2ext.init()

sdl2/test/sdl2ext_resources_test.py

 from ..ext import resources
 
 
-class ResourcesTest(unittest.TestCase):
+class SDL2ExtResourcesTest(unittest.TestCase):
+    __tags__ = ["sdl2ext"]
 
     def test_open_zipfile(self):
         fpath = os.path.join(os.path.dirname(__file__), "resources")

sdl2/test/sdl2ext_scene_test.py

 from ..ext import scene
 
 
-class SceneTest(unittest.TestCase):
-    __tags__ = ["scene"]
+class SDL2ExtSceneTest(unittest.TestCase):
+    __tags__ = ["scene", "sdl2ext"]
 
     def test_SceneManager(self):
         mgr = scene.SceneManager()

sdl2/test/sdl2ext_sprite_test.py

         return self._size
 
 
-class VideoSpriteTest(unittest.TestCase):
-    __tags__ = ["sdl"]
+class SDL2ExtSpriteTest(unittest.TestCase):
+    __tags__ = ["sdl", "sdl2ext"]
 
     def setUp(self):
-        if sys.version.startswith("3.1"):
-            self.assertIsInstance = \
-                lambda x, t: self.assertTrue(isinstance(x, t))
         sdl2ext.init()
 
     def tearDown(self):

sdl2/test/sdl2ext_test.py

 from .. import SDL_WasInit, SDL_INIT_VIDEO
 
 
-class VideoTest(unittest.TestCase):
-    __tags__ = ["sdl"]
+class SDL2ExtTest(unittest.TestCase):
+    __tags__ = ["sdl", "sdl2ext"]
 
     def test_init_quit(self):
         sdl2ext.init()

sdl2/test/sdl2ext_window_test.py

 from .util.testutils import interactive, doprint
 
 
-class VideoWindowTest(unittest.TestCase):
-    __tags__ = ["sdl"]
+class SDL2ExtWindowTest(unittest.TestCase):
+    __tags__ = ["sdl", "sdl2ext"]
 
     def setUp(self):
         sdl2ext.init()

sdl2/test/sdlimage_test.py

 from .. import SDL_Init, SDL_Quit, version, surface, rwops, render
 from .. import sdlimage
 
-formats = ("bmp",
+formats = ["bmp",
            "cur",
            "gif",
            "ico",
            "jpg",
-           # "lbm",
+           "lbm",
            "pbm",
            "pcx",
            "pgm",
            "tga",
            "tif",
            "webp",
-           "xcf",
+           #"xcf",
            "xpm",
-           # "xv",
-           )
+           #"xv",
+           ]
+
+if sys.version_info[:2] == (3, 3) and sys.platform in ("win32", "cli"):
+    # TODO: fix this - lbm and pbm crash Python 3.3 on Win32 - maybe an
+    # issue in SDL2_image?
+    formats.remove("lbm")
+    formats.remove("pbm")
 
 
 class SDLImageTest(unittest.TestCase):

sdl2/test/version_test.py

         self.assertEqual(version.SDL_GetRevision()[0:3], b"hg-")
 
     def test_SDL_GetRevisionNumber(self):
-        self.assertGreaterEqual(version.SDL_GetRevisionNumber(), 6380)
+        if sys.platform in ("win32", "cli"):
+            # HG tip on Win32 does not set any revision number
+            self.assertGreaterEqual(version.SDL_GetRevisionNumber(), 0)
+        else:
+            self.assertGreaterEqual(version.SDL_GetRevisionNumber(), 7000)
 
 
 if __name__ == '__main__':

sdl2/test/video_test.py

 import sys
 from ctypes.util import find_library
-from ctypes import c_int, byref, cast, py_object, POINTER
+from ctypes import c_int, byref, cast, POINTER
 import unittest
 from .util.testutils import interactive, doprint
 from ..stdinc import SDL_FALSE, SDL_TRUE
             gammas = (x * 0.1 for x in range(0, 20))
             count = 0
             for b in gammas:
-                try:
-                    video.SDL_SetWindowBrightness(window, b)
-                except:
-                    pass  # ignore the issue, if the gamma is not supported
-                else:
+                ret = video.SDL_SetWindowBrightness(window, b)
+                if ret == 0:
                     val = video.SDL_GetWindowBrightness(window)
                     self.assertAlmostEqual(val, b)
                     count += 1
         video.SDL_GL_UnloadLibrary()
 
         if has_opengl_lib():
-            self.assertTrue(video.SDL_GL_LoadLibrary(get_opengl_path()))
+            self.assertEqual(video.SDL_GL_LoadLibrary(get_opengl_path().encode("utf-8")), 0)
             video.SDL_GL_UnloadLibrary()
 
         #self.assertRaises(sdl.SDLError, video.SDL_GL_LoadLibrary, "Test")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.