Marcus von Appen avatar Marcus von Appen committed d5a140a

- fixed SDL_WindowGetData() and SDL_WindowSetData() wrappers
- minor documentation improvements
- minor pep8 improvements
- fixed and improved several unittests

Comments (0)

Files changed (41)

 You must have at least one of the following Python versions installed:
 
 * Python 2.7, 3.2+     (http://www.python.org)
-* PyPy 1.9.0+          (http://www.pypy.org)
+* PyPy 1.8.0+          (http://www.pypy.org)
 
 Other Python versions or Python implementations might work, but are
 (currently) not officially tested or supported by the PySDL2
 
 .. note::
 
-   If you did not install SDL2 using preferred way for your operation system,
-   please read the information about :ref:`importing-pysdl2` in the section
-   :doc:`integration`.
+   If you did not install SDL2 using the preferred way for your operation
+   system, please read the information about :ref:`importing-pysdl2` in the
+   section :doc:`integration`.
 
 Notes on Mercurial usage
 ^^^^^^^^^^^^^^^^^^^^^^^^

doc/tutorial/helloworld.rst

 Hello World
 ===========
 Ahhh, the great tradition of saying "Hello World" in a programming
-language. To whet your appetite, we will do the same with a most simple
-application, which will display a logo. It is not important to understand
+language. To whet your appetite, we will do this with a most simple
+application, which will display an image. It is not important to understand
 everything at once, which will be used by the example. Nearly all parts used
 now are explained in later chapters, so do not hesitate, if the one or other
 explanation is missing.
 Any graphical application requires access to the screen, mostly in form
 of a window, which basically represents a portion of the screen, the
 application has access to and the application can manipulate. In most cases
-that portion has a border and title bar around it, so the user can move
-it around on the screen and reorganize anything, so it fits his needs.
+that portion has a border and title bar around it, allowing the user to move
+it around on the screen and reorganize everythingin a way to fit his needs.
 
 Once we have imported all necessary parts, let's create a window to have
 access to the screen, so we can display the logo and thus represent it
     spriterenderer = factory.create_sprite_renderer(window)
     spriterenderer.render(sprite)
 
-First, we initialize the :mod:`sdl2.ext` internals, so we can have
-access to the screen and create windows on top of it. Once done with that,
+First, we initialize the :mod:`sdl2.ext` internals to gain access to the
+screen and and to be able to create windows on top of it. Once done with that,
 :class:`sdl2.ext.Window` will create the window for us and we
 supply a title to be shown on the window's border along with its initial size.
 Since :class:`sdl2.ext.Window` instances are not shown by default,
 To display the image, we will use a :class:`sdl2.ext.SpriteRenderer`,
 which supports the sprite type (texture- or software-based) and can copy the
 image to the window for display. The :class:`sdl2.ext.SpriteRenderer`
-needs to know, where to copy to, so we supply the window as target for copy
-and display operations.
+needs to know, where to copy to, thus we have to supply the window as target
+for copy and display operations.
 
-All left to do is to actually initiate the copy process by calling
+All left to do is to initiate the copy process by calling
 :class:`sdl2.ext.SpriteRenderer.render()` with the image we
 created earlier.
 
 
 Since this is a very first tutorial, we keep things simple here and use a
 dummy class for testing without actually dealing with the event loop magic.
-By calling :meth:`sdl2.ext.TestEventProcessor.run()`, we implicitly start the
-event loop, so that it can take care of everything for us.
+By calling :meth:`sdl2.ext.TestEventProcessor.run()`, we implicitly start an
+event loop, which takes care of the most important parts for us.
 
 And here it ends...
 -------------------
 The window is shown, the image is shown, great! All left to do is to clean up
 everything, once the application finishes. Luckily the
-:class:`sdl2.ext.TestEventProcessor` knows, when the window is closed, so
-it will exit from the event loop. Once it exits, we definitely should clean up
-the video internals, we initialized at the beginning. Thus, a final call to ::
+:class:`sdl2.ext.TestEventProcessor` knows when the window is closed, so
+it will exit from the event loop. Once it exits, we should clean up the
+video internals, we initialized at the beginning. Thus, a final call to ::
 
     sdl2ext.quit()
 
-should definitely be made.
+should be made.

doc/tutorial/pong.rst

 
 The Pong Game
 =============
-The following tutorial will show you some capabilities of the
-component-based approach, PySDL2 features. We will create the basics
-of a simple Pong game implementation here.
+The following tutorial will show you some capabilities of the component-based
+approach, PySDL2 features. We will create the basics of a simple Pong game
+implementation here. The basics of creating an own event loop, dealing with
+user input, moving images around and creating own rendering functions are
+covered in this tutorial.
 
 Getting started
 ---------------
 
 .. rubric:: Footnotes
 
-.. [#f1]  Component-Oriented Programming   
+.. [#f1]  Component-Oriented Programming   
 
 __all__ = ["get_dll_file"]
 
+
 def _findlib(libnames, path=None):
     """."""
     platform = sys.platform
 
 dll = _DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
 
+
 def get_dll_file():
     """Gets the file name of the loaded SDL2 library."""
     return dll.libfile

sdl2/ext/common.py

                     break
             window.refresh()
             timer.SDL_Delay(10)
-
         True, the system will operate on combined sets of components.
         """
         if not self._system_is_valid(system):
-            raise ValueError("system must have componenttypes and a process method")
+            raise ValueError("""system must have componenttypes and a process
+method""")
         for classtype in system.componenttypes:
             if classtype not in self.components:
                 self.add_componenttype(classtype)
         self._systems.append(system)
 
-
     def insert_system(self, index, system):
         """Adds a processing system to the world.
 
         processing order.
         """
         if not self._system_is_valid(system):
-            raise ValueError("system must have componenttypes and a process method")
+            raise ValueError("""system must have componenttypes and a process
+method""")
         for classtype in system.componenttypes:
             if classtype not in self.components:
                 self.add_componenttype(classtype)

sdl2/ext/events.py

     fargs = args[2]
     return args[0](args[1], *fargs)
 
+
 class MPEventHandler(EventHandler):
     """An asynchronous event handling class in which callbacks are
     executed in parallel.

sdl2/ext/pixelaccess.py

         raise ValueError("unsupported bpp")
     strides = (psurface.pitch, bpp)
     srcsize = psurface.h * psurface.pitch
-    shape = psurface.h, psurface.w  #surface.pitch // bpp
+    shape = psurface.h, psurface.w   # surface.pitch // bpp
 
     dtypes = {1: numpy.uint8,
               2: numpy.uint16,

sdl2/ext/sprite.py

 
 class RenderContext(object):
     """SDL2-based rendering context for windows and sprites."""
-    def __init__(self, target, index= -1,
+    def __init__(self, target, index=-1,
                  flags=render.SDL_RENDERER_ACCELERATED):
         """Creates a new RenderContext for the given target.
 
         self.renderer = None
         self.rendertaget = None
         if isinstance(target, Window):
-            self.renderer = render.SDL_CreateRenderer(target.window, index, flags)
+            self.renderer = render.SDL_CreateRenderer(target.window, index,
+                                                      flags)
             self.rendertarget = target.window
         elif isinstance(target, video.SDL_Window):
             self.renderer = render.SDL_CreateRenderer(target, index, flags)
             if color:
                 tmp = self.color
                 self.color = color
-            ret = render.SDL_RenderDrawPoint(self.renderer, points[0], points[1])
+            ret = render.SDL_RenderDrawPoint(self.renderer, points[0],
+                                             points[1])
             if color:
                 self.color = tmp
             if ret == -1:
         super(SoftwareSprite, self).__init__()
         self.free = free
         if not isinstance(imgsurface, surface.SDL_Surface):
-            raise TypeError ("surface must be a SDL_Surface")
+            raise TypeError("surface must be a SDL_Surface")
         self.surface = imgsurface
 
     def __del__(self):
         access = c_int()
         w = c_int()
         h = c_int()
-        ret = render.SDL_QueryTexture(self.texture, byref(flags), byref(access),
-                                      byref(w), byref(h))
+        ret = render.SDL_QueryTexture(self.texture, byref(flags),
+                                      byref(access), byref(w), byref(h))
         if ret == -1:
             raise SDLError()
         static = "True"
         x and y are optional arguments that can be used as relative
         drawing location for sprites. If set to None, the location
         information of the sprites are used. If set and sprites is an
-        iterable, such as a list of SoftwareSprite objects, x and y are relative
-        location values that will be added to each individual sprite's
+        iterable, such as a list of SoftwareSprite objects, x and y are
+        relative location values that will be added to each individual sprite's
         position. If sprites is a single SoftwareSprite, x and y denote the
         absolute position of the SoftwareSprite, if set.
         """

sdl2/test/audio_test.py

     SDL_INIT_AUDIO
 from .. import audio
 
+
 class SDLAudioTest(unittest.TestCase):
     __tags__ = ["sdl"]
 
         # self.assertRaises(SDLError, audio.SDL_GetAudioDriver, -1)
         # self.assertRaises(SDLError, audio.get_audio_driver,
         #                  drivercount + 1)
-        self.assertRaises(ctypes.ArgumentError, audio.SDL_GetAudioDriver, "Test")
+        self.assertRaises(ctypes.ArgumentError, audio.SDL_GetAudioDriver,
+                          "Test")
         self.assertRaises(ctypes.ArgumentError, audio.SDL_GetAudioDriver, None)
 
     def test_SDL_GetCurrentAudioDriver(self):
             spec = audio.SDL_AudioSpec()
             name = audio.SDL_GetAudioDeviceName(x, 0)
             self.assertIsNotNone(name)
-            deviceid = audio.SDL_OpenAudioDevice(None, 0, reqspec, ctypes.byref(spec), 1)
+            deviceid = audio.SDL_OpenAudioDevice(None, 0, reqspec,
+                                                 ctypes.byref(spec), 1)
             self.assertGreaterEqual(deviceid, 2)
             self.assertIsInstance(spec, audio.SDL_AudioSpec)
             self.assertEqual(spec.format, reqspec.format)

sdl2/test/clipboard_test.py

 import sys
 import unittest
-from .. import SDL_Init, SDL_Quit, SDL_InitSubSystem, SDL_QuitSubSystem, \
-    SDL_INIT_EVERYTHING
+from .. import SDL_Init, SDL_Quit, SDL_InitSubSystem, SDL_INIT_EVERYTHING
 from .. import clipboard
-from ..stdinc import SDL_TRUE, SDL_FALSE
+from ..stdinc import SDL_TRUE
 from .util.testutils import interactive, doprint
 
+
 def is_win_or_mac():
     return sys.platform in ("win32", "cygwin", "darwin", "cli")
 
         retval = clipboard.SDL_GetClipboardText()
         self.assertEqual(retval, b"")
 
+
 if __name__ == '__main__':
     sys.exit(unittest.main())

sdl2/test/cpuinfo_test.py

         ret = cpuinfo.SDL_HasSSE42()
         self.assertIn(ret, (0, 1))
 
+
 if __name__ == '__main__':
     sys.exit(unittest.main())

sdl2/test/endian_test.py

             self.assertEqual(endian.SDL_Swap32, endian.SDL_SwapLE32)
 
     def test_SDL_Swap64(self):
-        self.assertEqual(endian.SDL_Swap64(0xFF00000000000000), 0x00000000000000FF)
-        self.assertEqual(endian.SDL_Swap64(0x00FF000000000000), 0x000000000000FF00)
-        self.assertEqual(endian.SDL_Swap64(0x0000FF0000000000), 0x0000000000FF0000)
-        self.assertEqual(endian.SDL_Swap64(0x000000FF00000000), 0x00000000FF000000)
-        self.assertEqual(endian.SDL_Swap64(0x00000000FF000000), 0x000000FF00000000)
-        self.assertEqual(endian.SDL_Swap64(0x0000000000FF0000), 0x0000FF0000000000)
-        self.assertEqual(endian.SDL_Swap64(0x000000000000FF00), 0x00FF000000000000)
-        self.assertEqual(endian.SDL_Swap64(0x00000000000000FF), 0xFF00000000000000)
-        self.assertEqual(endian.SDL_Swap64(0x0123456789ABCDEF), 0xEFCDAB8967452301)
+        self.assertEqual(endian.SDL_Swap64(0xFF00000000000000),
+                         0x00000000000000FF)
+        self.assertEqual(endian.SDL_Swap64(0x00FF000000000000),
+                         0x000000000000FF00)
+        self.assertEqual(endian.SDL_Swap64(0x0000FF0000000000),
+                         0x0000000000FF0000)
+        self.assertEqual(endian.SDL_Swap64(0x000000FF00000000),
+                         0x00000000FF000000)
+        self.assertEqual(endian.SDL_Swap64(0x00000000FF000000),
+                         0x000000FF00000000)
+        self.assertEqual(endian.SDL_Swap64(0x0000000000FF0000),
+                         0x0000FF0000000000)
+        self.assertEqual(endian.SDL_Swap64(0x000000000000FF00),
+                         0x00FF000000000000)
+        self.assertEqual(endian.SDL_Swap64(0x00000000000000FF),
+                         0xFF00000000000000)
+        self.assertEqual(endian.SDL_Swap64(0x0123456789ABCDEF),
+                         0xEFCDAB8967452301)
         if sys.byteorder == "little":
             self.assertEqual(endian.SDL_Swap64, endian.SDL_SwapBE64)
             self.assertNotEqual(endian.SDL_Swap64, endian.SDL_SwapLE64)

sdl2/test/events_test.py

         pass
         # state = events.SDL_EventState(events.SDL_USEREVENT, events.SDL_QUERY)
         # self.assertEqual(state, events.SDL_ENABLE)
-        # state = events.SDL_EventState(events.SDL_USEREVENT, events.SDL_IGNORE)
+        # state = events.SDL_EventState(events.SDL_USEREVENT,events.SDL_IGNORE)
         # self.assertEqual(state, events.SDL_ENABLE)
         # state = events.SDL_EventState(events.SDL_USEREVENT, events.SDL_QUERY)
         # self.assertEqual(state, events.SDL_IGNORE)
-        # state = events.SDL_EventState(events.SDL_USEREVENT, events.SDL_ENABLE)
+        # state = events.SDL_EventState(events.SDL_USEREVENT,events.SDL_ENABLE)
         # self.assertEqual(state, events.SDL_IGNORE)
         # state = events.SDL_EventState(events.SDL_USEREVENT, events.SDL_QUERY)
         # self.assertEqual(state, events.SDL_ENABLE)
         # ev.user = events.SDL_UserEvent()
         # events.SDL_PushEvent(ev)
 
-
     @unittest.skip("not implemented")
     def test_SDL_GetEventState(self):
         pass
     def test_SDL_QuitRequested(self):
         pass
 
+
 if __name__ == '__main__':
     sys.exit(unittest.main())

sdl2/test/hints_test.py

         self.assertEqual(hints.SDL_GetHint(b"TEST"), b"32")
         self.assertEqual(hints.SDL_SetHint(hints.SDL_HINT_RENDER_DRIVER,
                                            b"dummy"), 1)
-        self.assertEqual(hints.SDL_GetHint(hints.SDL_HINT_RENDER_DRIVER), b"dummy")
+        self.assertEqual(hints.SDL_GetHint(hints.SDL_HINT_RENDER_DRIVER),
+                         b"dummy")
 
     def test_SDL_SetHint(self):
         self.assertEqual(hints.SDL_SetHint(b"TEST", b"32"), 1)
         # self.assertRaises(ValueError, hints.SDL_SetHintWithPriority,
         #                  "TEST", "123456789", "bananas")
 
+
 if __name__ == '__main__':
     sys.exit(unittest.main())

sdl2/test/joystick_test.py

             name = joystick.SDL_JoystickNameForIndex(index)
             self.assertIn(type(name), (str, bytes))
 
-        # self.assertRaises(sdl.SDLError, joystick.joystick_name, self.jcount + 1)
+        # self.assertRaises(sdl.SDLError, joystick.joystick_name,
+        #                   self.jcount + 1)
         # self.assertRaises(sdl.SDLError, joystick.joystick_name, -10)
         # self.assertRaises(ValueError, joystick.joystick_name, "Test")
         # self.assertRaises(TypeError, joystick.joystick_name, None)
             joystick.SDL_JoystickClose(stick)
             # self.assertFalse(joystick.joystick_opened(index))
 
-        # self.assertRaises(sdl.SDLError, joystick.joystick_open, self.jcount + 1)
+        # self.assertRaises(sdl.SDLError, joystick.joystick_open,
+        #                   self.jcount + 1)
         # self.assertRaises(sdl.SDLError, joystick.joystick_open, -10)
         # self.assertRaises(ValueError, joystick.joystick_open, "Test")
         # self.assertRaises(TypeError, joystick.joystick_open, None)

sdl2/test/keyboard_test.py

 import unittest
 from .. import SDL_Init, SDL_Quit, SDL_QuitSubSystem, SDL_INIT_VIDEO
 from .. import rect, keyboard, scancode, keycode, video
-import ctypes
+from ctypes import c_int, cast, POINTER
 
 byteify = lambda x: x.encode("utf-8")
 
+
 class SDLKeyboardTest(unittest.TestCase):
     __tags__ = ["sdl"]
 
         # self.assertEqual(window, None)
 
     def test_SDL_GetKeyboardState(self):
-        states = (ctypes.c_int * scancode.SDL_NUM_SCANCODES)()
-        keyboard.SDL_GetKeyboardState(ctypes.cast(states, ctypes.POINTER(ctypes.c_int)))
+        states = (c_int * scancode.SDL_NUM_SCANCODES)()
+        keyboard.SDL_GetKeyboardState(cast(states, POINTER(c_int)))
         self.assertEqual(len(states), scancode.SDL_NUM_SCANCODES)
         # TODO: x
         # for state in states:

sdl2/test/log_test.py

 
 _ISIPY = sys.platform == "cli"
 
+
 @unittest.skipIf(_ISIPY, "IronPython does not handle exceptions correctly")
 class SDLLogTest(unittest.TestCase):
     __tags__ = ["sdl"]
         # setUp should have set our output function already.
         origfunc = log.SDL_LogOutputFunction()
         origdata = ctypes.c_void_p(0)
-        log.SDL_LogGetOutputFunction(ctypes.byref(origfunc), ctypes.byref(origdata))
+        log.SDL_LogGetOutputFunction(ctypes.byref(origfunc),
+                                     ctypes.byref(origdata))
         self.assertFalse(origdata)
         logcount = len(self.logdata)
         origfunc(None, 0, 0, b"test_log_get_set_output_function")

sdl2/test/mouse_test.py

 import sys
-import os
 import unittest
-from ctypes import c_int, byref
 from .. import mouse
 
 

sdl2/test/pixels_test.py

 import sys
 import unittest
 import copy
-import ctypes
+from ctypes import c_int, POINTER, byref, cast, ArgumentError
 from .. import SDL_Init, SDL_Quit, SDL_QuitSubSystem, SDL_INIT_EVERYTHING
 from .. import pixels
 from ..pixels import SDL_Color
 from ..stdinc import Uint8, Uint16, Uint32
 
+
 class SDLPixelsTest(unittest.TestCase):
     __tags__ = ["sdl"]
 
         self.assertEqual(val, pixels.SDL_PIXELFORMAT_UNKNOWN)
 
     def test_SDL_PixelFormatEnumToMasks(self):
-        bpp, r, g, b, a = ctypes.c_int(), Uint32(), Uint32(), Uint32(), Uint32()
-        pixels.SDL_PixelFormatEnumToMasks(pixels.SDL_PIXELFORMAT_INDEX1LSB, ctypes.byref(bpp), ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
-        self.assertEqual((bpp.value, r.value, g.value, b.value, a.value), (1, 0, 0, 0, 0))
-        pixels.SDL_PixelFormatEnumToMasks(pixels.SDL_PIXELFORMAT_INDEX1MSB, ctypes.byref(bpp), ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
-        self.assertEqual((bpp.value, r.value, g.value, b.value, a.value), (1, 0, 0, 0, 0))
+        bpp = c_int()
+        r, g, b, a = Uint32(), Uint32(), Uint32(), Uint32()
+        pixels.SDL_PixelFormatEnumToMasks(pixels.SDL_PIXELFORMAT_INDEX1LSB,
+                                          byref(bpp), byref(r), byref(g),
+                                          byref(b), byref(a))
+        self.assertEqual((bpp.value, r.value, g.value, b.value, a.value),
+                         (1, 0, 0, 0, 0))
+        pixels.SDL_PixelFormatEnumToMasks(pixels.SDL_PIXELFORMAT_INDEX1MSB,
+                                          byref(bpp), byref(r), byref(g),
+                                          byref(b), byref(a))
+        self.assertEqual((bpp.value, r.value, g.value, b.value, a.value),
+                         (1, 0, 0, 0, 0))
 
-        pixels.SDL_PixelFormatEnumToMasks(pixels.SDL_PIXELFORMAT_RGBA8888, ctypes.byref(bpp), ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
+        pixels.SDL_PixelFormatEnumToMasks(pixels.SDL_PIXELFORMAT_RGBA8888,
+                                          byref(bpp), byref(r), byref(g),
+                                          byref(b), byref(a))
         if sys.byteorder == "little":
-            self.assertEqual((bpp.value, r.value, g.value, b.value, a.value), (32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF))
+            self.assertEqual((bpp.value, r.value, g.value, b.value, a.value),
+                             (32, 0xFF000000, 0x00FF0000, 0x0000FF00,
+                              0x000000FF))
         else:
-            self.assertEqual((bpp.value, r.value, g.value, b.value, a.value), (32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000))
-        pixels.SDL_PixelFormatEnumToMasks(pixels.SDL_PIXELFORMAT_RGBX8888, ctypes.byref(bpp), ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
+            self.assertEqual((bpp.value, r.value, g.value, b.value, a.value),
+                             (32, 0x000000FF, 0x0000FF00, 0x00FF0000,
+                              0xFF000000))
+        pixels.SDL_PixelFormatEnumToMasks(pixels.SDL_PIXELFORMAT_RGBX8888,
+                                          byref(bpp), byref(r),
+                                          byref(g), byref(b),
+                                          byref(a))
         if sys.byteorder == "little":
-            self.assertEqual((bpp.value, r.value, g.value, b.value, a.value), (32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0))
+            self.assertEqual((bpp.value, r.value, g.value, b.value, a.value),
+                             (32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0))
         else:
-            self.assertEqual((bpp.value, r.value, g.value, b.value, a.value), (32, 0, 0x0000FF00, 0x00FF0000, 0xFF000000))
-        # self.assertRaises(sdl.SDLError, pixels.SDL_PixelFormatEnumToMasks, 99999)
+            self.assertEqual((bpp.value, r.value, g.value, b.value, a.value),
+                             (32, 0, 0x0000FF00, 0x00FF0000, 0xFF000000))
+        # self.assertRaises(sdl.SDLError, pixels.SDL_PixelFormatEnumToMasks,
+        #                   99999)
 
-        pixels.SDL_PixelFormatEnumToMasks(0, ctypes.byref(bpp), ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
-        self.assertEqual((bpp.value, r.value, g.value, b.value, a.value), (0, 0, 0, 0, 0))
-        pixels.SDL_PixelFormatEnumToMasks(pixels.SDL_PIXELFORMAT_UNKNOWN, ctypes.byref(bpp), ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
-        self.assertEqual((bpp.value, r.value, g.value, b.value, a.value), (0, 0, 0, 0, 0))
+        pixels.SDL_PixelFormatEnumToMasks(0, byref(bpp), byref(r), byref(g),
+                                          byref(b), byref(a))
+        self.assertEqual((bpp.value, r.value, g.value, b.value, a.value),
+                         (0, 0, 0, 0, 0))
+        pixels.SDL_PixelFormatEnumToMasks(pixels.SDL_PIXELFORMAT_UNKNOWN,
+                                          byref(bpp), byref(r), byref(g),
+                                          byref(b), byref(a))
+        self.assertEqual((bpp.value, r.value, g.value, b.value, a.value),
+                         (0, 0, 0, 0, 0))
 
     def test_SDL_AllocFreeFormat(self):
         pformat = pixels.SDL_AllocFormat(pixels.SDL_PIXELFORMAT_RGBA8888)
         self.assertIsInstance(pformat.contents, pixels.SDL_PixelFormat)
-        self.assertEqual(pformat.contents.format, pixels.SDL_PIXELFORMAT_RGBA8888)
+        self.assertEqual(pformat.contents.format,
+                         pixels.SDL_PIXELFORMAT_RGBA8888)
         self.assertEqual(pformat.contents.BitsPerPixel, 32)
         self.assertEqual(pformat.contents.BytesPerPixel, 4)
         pixels.SDL_FreeFormat(pformat)
 
         pformat = pixels.SDL_AllocFormat(pixels.SDL_PIXELFORMAT_INDEX1LSB)
         self.assertIsInstance(pformat.contents, pixels.SDL_PixelFormat)
-        self.assertEqual(pformat.contents.format, pixels.SDL_PIXELFORMAT_INDEX1LSB)
+        self.assertEqual(pformat.contents.format,
+                         pixels.SDL_PIXELFORMAT_INDEX1LSB)
         self.assertEqual(pformat.contents.BitsPerPixel, 1)
         self.assertEqual(pformat.contents.BytesPerPixel, 1)
         pixels.SDL_FreeFormat(pformat)
 
         pformat = pixels.SDL_AllocFormat(pixels.SDL_PIXELFORMAT_INDEX4MSB)
         self.assertIsInstance(pformat.contents, pixels.SDL_PixelFormat)
-        self.assertEqual(pformat.contents.format, pixels.SDL_PIXELFORMAT_INDEX4MSB)
+        self.assertEqual(pformat.contents.format,
+                         pixels.SDL_PIXELFORMAT_INDEX4MSB)
         self.assertEqual(pformat.contents.BitsPerPixel, 4)
         self.assertEqual(pformat.contents.BytesPerPixel, 1)
         pixels.SDL_FreeFormat(pformat)
         #                   pixels.SDL_PIXELFORMAT_YUY2)
 
     def test_SDL_AllocFreePalette(self):
-        self.assertRaises(ctypes.ArgumentError, pixels.SDL_AllocPalette, None)
-        self.assertRaises(ctypes.ArgumentError, pixels.SDL_AllocPalette, "Test")
+        self.assertRaises(ArgumentError, pixels.SDL_AllocPalette, None)
+        self.assertRaises(ArgumentError, pixels.SDL_AllocPalette,
+                          "Test")
         # self.assertRaises(ValueError, pixels.SDL_AllocPalette, -5)
 
         palette = pixels.SDL_AllocPalette(10)
         self.assertRaises(TypeError, pixels.SDL_CalculateGammaRamp, 7)
         self.assertRaises(TypeError, pixels.SDL_CalculateGammaRamp, -0.00002)
         vals = (Uint16 * 256)()
-        pixels.SDL_CalculateGammaRamp(0, ctypes.cast(vals, ctypes.POINTER(Uint16)))
+        pixels.SDL_CalculateGammaRamp(0, cast(vals, POINTER(Uint16)))
         self.assertEqual(len(vals), 256)
         for x in vals:
             self.assertEqual(x, 0)
         vals = (Uint16 * 256)()
-        pixels.SDL_CalculateGammaRamp(1, ctypes.cast(vals, ctypes.POINTER(Uint16)))
+        pixels.SDL_CalculateGammaRamp(1, cast(vals, POINTER(Uint16)))
         self.assertEqual(len(vals), 256)
         p = 0
         for x in vals:
             self.assertEqual(x, p)
             p += 257
         vals = (Uint16 * 256)()
-        pixels.SDL_CalculateGammaRamp(0.5, ctypes.cast(vals, ctypes.POINTER(Uint16)))
+        pixels.SDL_CalculateGammaRamp(0.5, cast(vals, POINTER(Uint16)))
         self.assertEqual(len(vals), 256)
         p, step = 0, 1
         for x in vals:
         pformat = pixels.SDL_AllocFormat(pixels.SDL_PIXELFORMAT_RGBA8888)
         self.assertIsInstance(pformat.contents, pixels.SDL_PixelFormat)
         r, g, b = Uint8(), Uint8(), Uint8()
-        pixels.SDL_GetRGB(0xFFAA8811, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b))
+        pixels.SDL_GetRGB(0xFFAA8811, pformat, byref(r), byref(g), byref(b))
         self.assertEqual((r.value, g.value, b.value), (0xFF, 0xAA, 0x88))
-        pixels.SDL_GetRGB(0x00000000, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b))
+        pixels.SDL_GetRGB(0x00000000, pformat, byref(r), byref(g), byref(b))
         self.assertEqual((r.value, g.value, b.value), (0x00, 0x00, 0x00))
-        pixels.SDL_GetRGB(0xFFFFFFFF, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b))
+        pixels.SDL_GetRGB(0xFFFFFFFF, pformat, byref(r), byref(g), byref(b))
         self.assertEqual((r.value, g.value, b.value), (0xFF, 0xFF, 0xFF))
-        pixels.SDL_GetRGB(0x11223344, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b))
+        pixels.SDL_GetRGB(0x11223344, pformat, byref(r), byref(g), byref(b))
         self.assertEqual((r.value, g.value, b.value), (0x11, 0x22, 0x33))
         pixels.SDL_FreeFormat(pformat)
         fmts = (pixels.SDL_PIXELFORMAT_INDEX1LSB,
         for fmt in fmts:
             pformat = pixels.SDL_AllocFormat(fmt)
             self.assertIsInstance(pformat.contents, pixels.SDL_PixelFormat)
-            pixels.SDL_GetRGB(0x11223344, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b))
+            pixels.SDL_GetRGB(0x11223344, pformat, byref(r), byref(g),
+                              byref(b))
             self.assertEqual((r.value, g.value, b.value), (0xFF, 0xFF, 0xFF))
-            pixels.SDL_GetRGB(0x00000000, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b))
+            pixels.SDL_GetRGB(0x00000000, pformat, byref(r), byref(g),
+                              byref(b))
             # TODO: Seems to be always (0xFF, 0xFF, 0xFF)???
             # self.assertEqual(rgb,(0x00, 0x00, 0x00))
             pixels.SDL_FreeFormat(pformat)
         pformat = pixels.SDL_AllocFormat(pixels.SDL_PIXELFORMAT_RGBA8888)
         self.assertIsInstance(pformat.contents, pixels.SDL_PixelFormat)
         r, g, b, a = Uint8(), Uint8(), Uint8(), Uint8()
-        pixels.SDL_GetRGBA(0xFFAA8811, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
-        self.assertEqual((r.value, g.value, b.value, a.value), (0xFF, 0xAA, 0x88, 0x11))
-        pixels.SDL_GetRGBA(0x00000000, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
-        self.assertEqual((r.value, g.value, b.value, a.value), (0x00, 0x00, 0x00, 0x00))
-        pixels.SDL_GetRGBA(0xFFFFFFFF, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
-        self.assertEqual((r.value, g.value, b.value, a.value), (0xFF, 0xFF, 0xFF, 0xFF))
-        pixels.SDL_GetRGBA(0x11223344, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
-        self.assertEqual((r.value, g.value, b.value, a.value), (0x11, 0x22, 0x33, 0x44))
+        pixels.SDL_GetRGBA(0xFFAA8811, pformat, byref(r), byref(g), byref(b),
+                           byref(a))
+        self.assertEqual((r.value, g.value, b.value, a.value),
+                         (0xFF, 0xAA, 0x88, 0x11))
+        pixels.SDL_GetRGBA(0x00000000, pformat, byref(r), byref(g), byref(b),
+                           byref(a))
+        self.assertEqual((r.value, g.value, b.value, a.value),
+                         (0x00, 0x00, 0x00, 0x00))
+        pixels.SDL_GetRGBA(0xFFFFFFFF, pformat, byref(r), byref(g), byref(b),
+                           byref(a))
+        self.assertEqual((r.value, g.value, b.value, a.value),
+                         (0xFF, 0xFF, 0xFF, 0xFF))
+        pixels.SDL_GetRGBA(0x11223344, pformat, byref(r), byref(g), byref(b),
+                           byref(a))
+        self.assertEqual((r.value, g.value, b.value, a.value),
+                         (0x11, 0x22, 0x33, 0x44))
         pixels.SDL_FreeFormat(pformat)
         fmts = (pixels.SDL_PIXELFORMAT_INDEX1LSB,
                 pixels.SDL_PIXELFORMAT_INDEX1MSB)
         for fmt in fmts:
             pformat = pixels.SDL_AllocFormat(fmt)
             self.assertIsInstance(pformat.contents, pixels.SDL_PixelFormat)
-            pixels.SDL_GetRGBA(0x11223344, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
-            self.assertEqual((r.value, g.value, b.value, a.value), (0xFF, 0xFF, 0xFF, 0xFF))
-            pixels.SDL_GetRGBA(0x00000000, pformat, ctypes.byref(r), ctypes.byref(g), ctypes.byref(b), ctypes.byref(a))
+            pixels.SDL_GetRGBA(0x11223344, pformat, byref(r), byref(g),
+                               byref(b), byref(a))
+            self.assertEqual((r.value, g.value, b.value, a.value),
+                             (0xFF, 0xFF, 0xFF, 0xFF))
+            pixels.SDL_GetRGBA(0x00000000, pformat, byref(r), byref(g),
+                               byref(b), byref(a))
             # TODO: Seems to be always(0xFF, 0xFF, 0xFF) ???
             # self.assertEqual(rgb,(0x00, 0x00, 0x00))
             pixels.SDL_FreeFormat(pformat)
 
         pformat = pixels.SDL_AllocFormat(pixels.SDL_PIXELFORMAT_UNKNOWN)
         self.assertIsInstance(pformat.contents, pixels.SDL_PixelFormat)
-        self.assertEqual(pformat.contents.format, pixels.SDL_PIXELFORMAT_UNKNOWN)
+        self.assertEqual(pformat.contents.format,
+                         pixels.SDL_PIXELFORMAT_UNKNOWN)
         val = pixels.SDL_MapRGB(pformat, 0xFF, 0xAA, 0x88)
         self.assertEqual(val, 0x0)
         pixels.SDL_FreeFormat(pformat)
 
         pformat = pixels.SDL_AllocFormat(pixels.SDL_PIXELFORMAT_UNKNOWN)
         self.assertIsInstance(pformat.contents, pixels.SDL_PixelFormat)
-        self.assertEqual(pformat.contents.format, pixels.SDL_PIXELFORMAT_UNKNOWN)
+        self.assertEqual(pformat.contents.format,
+                         pixels.SDL_PIXELFORMAT_UNKNOWN)
         val = pixels.SDL_MapRGBA(pformat, 0xFF, 0xAA, 0x88, 0x11)
         self.assertEqual(val, 0x0)
         pixels.SDL_FreeFormat(pformat)

sdl2/test/power_test.py

         elif retval == power.SDL_POWERSTATE_CHARGED:
             state = "Battery charged"
         output = "Power Status: %s" % state + os.linesep
-        output += "Minutes left (-1 = undetermined): %d" % (secs.value / 60) + \
-            os.linesep
-        output += "Percent left (-1 = undetermined): %d" % percent.value + \
-            os.linesep
+        output += "Minutes left (-1 = undetermined): %d" % (secs.value / 60)
+        output += os.linesep
+        output += "Percent left (-1 = undetermined): %d" % percent.value
+        output += os.linesep
         doprint(output)
 
 

sdl2/test/rect_test.py

     def test_SDL_IntersectRectAndLine(self):
         r = rect.SDL_Rect()
         x1, y1, x2, y2 = c_int(-5), c_int(-5), c_int(5), c_int(5)
-        ret = rect.SDL_IntersectRectAndLine(r, byref(x1), byref(y1), byref(x2), byref(y2))
+        ret = rect.SDL_IntersectRectAndLine(r, byref(x1), byref(y1),
+                                            byref(x2), byref(y2))
         self.assertFalse(ret)
 
         r = rect.SDL_Rect(0, 0, 2, 2)
         x1, y1, x2, y2 = c_int(-1), c_int(-1), c_int(3), c_int(3)
-        ret = rect.SDL_IntersectRectAndLine(r, byref(x1), byref(y1), byref(x2), byref(y2))
+        ret = rect.SDL_IntersectRectAndLine(r, byref(x1), byref(y1),
+                                            byref(x2), byref(y2))
         self.assertTrue(ret)
-        self.assertEqual((x1.value, y1.value, x2.value, y2.value), (0, 0, 1, 1))
+        self.assertEqual((x1.value, y1.value, x2.value, y2.value),
+                         (0, 0, 1, 1))
 
         r = rect.SDL_Rect(-4, -4, 14, 14)
         x1, y1, x2, y2 = c_int(8), c_int(22), c_int(8), c_int(33)
-        ret = rect.SDL_IntersectRectAndLine(r, byref(x1), byref(y1), byref(x2), byref(y2))
+        ret = rect.SDL_IntersectRectAndLine(r, byref(x1), byref(y1),
+                                            byref(x2), byref(y2))
         self.assertFalse(ret)
         # TODO
 
         pt2 = rect.SDL_Point(5, 7)
         clip = rect.SDL_Rect(0, 0, 10, 10)
         res = rect.SDL_Rect()
-        ret = rect.SDL_EnclosePoints(to_ctypes([pt1, pt2], rect.SDL_Point), 2, byref(clip), byref(res))
+        ret = rect.SDL_EnclosePoints(to_ctypes([pt1, pt2], rect.SDL_Point), 2,
+                                     byref(clip), byref(res))
         self.assertTrue(ret)
         self.assertEqual(res, rect.SDL_Rect(0, 0, 6, 8))
 
         clip = rect.SDL_Rect(-10, -10, 3, 3)
-        ret = rect.SDL_EnclosePoints(to_ctypes([pt1, pt2], rect.SDL_Point), 2, byref(clip), byref(res))
+        ret = rect.SDL_EnclosePoints(to_ctypes([pt1, pt2], rect.SDL_Point), 2,
+                                     byref(clip), byref(res))
         self.assertFalse(ret)
         self.assertNotEqual(res, rect.SDL_Rect(0, 0, 0, 0))
 
-        ret = rect.SDL_EnclosePoints(to_ctypes([pt1, pt2], rect.SDL_Point), 2, None, byref(res))
+        ret = rect.SDL_EnclosePoints(to_ctypes([pt1, pt2], rect.SDL_Point), 2,
+                                     None, byref(res))
         self.assertTrue(ret)
         self.assertEqual(res, rect.SDL_Rect(0, 0, 6, 8))
 
         self.assertRaises(TypeError, rect.SDL_EnclosePoints, None, None)
         if sys.platform != "cli":  # IronPython can't handle this correctly
             self.assertRaises(TypeError, rect.SDL_EnclosePoints, "Test", None)
-            self.assertRaises(TypeError, rect.SDL_EnclosePoints, (1, 2, 3), None)
+            self.assertRaises(TypeError, rect.SDL_EnclosePoints, (1, 2, 3),
+                              None)
             self.assertRaises(TypeError, rect.SDL_EnclosePoints, (None,), None)
 
     def test_SDL_HasIntersection(self):

sdl2/test/render_test.py

 from ..stdinc import Uint8, Uint32, SDL_TRUE, SDL_FALSE
 from .. import render, video, surface, pixels, blendmode, rect
 
+
 # TODO: mostly positive tests, improve this!
 class SDLRenderTest(unittest.TestCase):
     __tags__ = ["sdl"]
         video.SDL_DestroyWindow(window)
 
     def test_SDL_CreateSoftwareRenderer(self):
-        sf = surface.SDL_CreateRGBSurface(0, 100, 100, 32, 0xFF000000, 0x00FF0000,
-                                          0x0000FF00, 0x000000FF)
+        sf = surface.SDL_CreateRGBSurface(0, 100, 100, 32,
+                                          0xFF000000,
+                                          0x00FF0000,
+                                          0x0000FF00,
+                                          0x000000FF)
         renderer = render.SDL_CreateSoftwareRenderer(sf)
         self.assertIsInstance(renderer.contents, render.SDL_Renderer)
         render.SDL_DestroyRenderer(renderer)
             self.assertEqual(ret, 0)
             render.SDL_DestroyRenderer(renderer)
 
-            #self.assertRaises(sdl.SDLError, render.SDL_GetRendererInfo, renderer)
+            #self.assertRaises(sdl.SDLError, render.SDL_GetRendererInfo,
+            #                  renderer)
 
         video.SDL_DestroyWindow(window)
         self.assertRaises((AttributeError, TypeError),
             for acc in access:
                 for w in range(1, 300, 5):
                     for h in range(1, 300, 5):
-                        tex = render.SDL_CreateTexture(renderer, fmt, acc, w, h)
+                        tex = render.SDL_CreateTexture(renderer, fmt, acc,
+                                                       w, h)
                         self.assertIsInstance(tex.contents, render.SDL_Texture)
                         render.SDL_DestroyTexture(tex)
 
             for acc in access:
                 for w in range(1, 300, 5):
                     for h in range(1, 300, 5):
-                        tex = render.SDL_CreateTexture(renderer, fmt, acc, w, h)
+                        tex = render.SDL_CreateTexture(renderer, fmt, acc,
+                                                       w, h)
                         self.assertIsInstance(tex.contents, render.SDL_Texture)
                         qf, qa, qw, qh = Uint32(), c_int(), c_int(), c_int()
-                        ret = render.SDL_QueryTexture(tex, byref(qf), byref(qa), byref(qw), byref(qh))
+                        ret = render.SDL_QueryTexture(tex, byref(qf),
+                                                      byref(qa), byref(qw),
+                                                      byref(qh))
                         self.assertEqual(ret, 0)
                         self.assertEqual(qf.value, fmt)
                         self.assertEqual(qa.value, acc)
                                              render.SDL_RENDERER_SOFTWARE)
         self.assertIsInstance(renderer.contents, render.SDL_Renderer)
 
-        tex = render.SDL_CreateTexture(renderer, pixels.SDL_PIXELFORMAT_ARGB8888,
-                                       render.SDL_TEXTUREACCESS_STREAMING, 10, 10)
+        tex = render.SDL_CreateTexture(renderer,
+                                       pixels.SDL_PIXELFORMAT_ARGB8888,
+                                       render.SDL_TEXTUREACCESS_STREAMING,
+                                       10, 10)
         self.assertIsInstance(tex.contents, render.SDL_Texture)
         colors = ((16, 22, 185),
                   (32, 64, 128),
             ret = render.SDL_SetTextureColorMod(tex, r, g, b)
             self.assertEqual(ret, 0)
             tr, tg, tb = Uint8(), Uint8(), Uint8()
-            ret = render.SDL_GetTextureColorMod(tex, byref(tr), byref(tg), byref(tb))
+            ret = render.SDL_GetTextureColorMod(tex, byref(tr), byref(tg),
+                                                byref(tb))
             self.assertEqual(ret, 0)
             self.assertEqual((tr.value, tg.value, tb.value), (r, g, b))
 
                                              render.SDL_RENDERER_SOFTWARE)
         self.assertIsInstance(renderer.contents, render.SDL_Renderer)
 
-        tex = render.SDL_CreateTexture(renderer, pixels.SDL_PIXELFORMAT_ARGB8888,
-                                       render.SDL_TEXTUREACCESS_STREAMING, 10, 10)
+        tex = render.SDL_CreateTexture(renderer,
+                                       pixels.SDL_PIXELFORMAT_ARGB8888,
+                                       render.SDL_TEXTUREACCESS_STREAMING,
+                                       10, 10)
         self.assertIsInstance(tex.contents, render.SDL_Texture)
 
         for alpha in range(0, 255):
                                              render.SDL_RENDERER_SOFTWARE)
         self.assertIsInstance(renderer.contents, render.SDL_Renderer)
 
-        tex = render.SDL_CreateTexture(renderer, pixels.SDL_PIXELFORMAT_ARGB8888,
-                                       render.SDL_TEXTUREACCESS_STREAMING, 10, 10)
+        tex = render.SDL_CreateTexture(renderer,
+                                       pixels.SDL_PIXELFORMAT_ARGB8888,
+                                       render.SDL_TEXTUREACCESS_STREAMING,
+                                       10, 10)
         self.assertIsInstance(tex.contents, render.SDL_Texture)
 
         modes = (blendmode.SDL_BLENDMODE_NONE,
         self.assertIsInstance(window.contents, video.SDL_Window)
 
         for i in range(render.SDL_GetNumRenderDrivers()):
-            renderer = render.SDL_CreateRenderer(window, i,
-                                                 render.SDL_RENDERER_ACCELERATED)
+            renderer = render.SDL_CreateRenderer\
+                (window, i, render.SDL_RENDERER_ACCELERATED)
             self.assertIsInstance(renderer.contents, render.SDL_Renderer)
 
             val = render.SDL_RenderTargetSupported(renderer)
 
         skipcount = 0
         for i in range(render.SDL_GetNumRenderDrivers()):
-            renderer = render.SDL_CreateRenderer(window, i,
-                                                 render.SDL_RENDERER_ACCELERATED)
+            renderer = render.SDL_CreateRenderer \
+                (window, i, render.SDL_RENDERER_ACCELERATED)
             self.assertIsInstance(renderer.contents, render.SDL_Renderer)
 
             supported = render.SDL_RenderTargetSupported(renderer)
                                            10, 10)
             ret = render.SDL_SetRenderTarget(renderer, tex)
             self.assertEqual(ret, 0)
-            self.assertIsInstance(render.SDL_GetRenderTarget(renderer).contents,
-                                  render.SDL_Texture)
+            tgt = render.SDL_GetRenderTarget(renderer)
+            self.assertIsInstance(tgt.contents, render.SDL_Texture)
             render.SDL_DestroyTexture(tex)
 
             # TODO: Check in the SDL codebase, why the code below does
         failcount = 0
         port = rect.SDL_Rect()
         for i in range(render.SDL_GetNumRenderDrivers()):
-            renderer = render.SDL_CreateRenderer(window, i,
-                                                 render.SDL_RENDERER_ACCELERATED)
+            renderer = render.SDL_CreateRenderer \
+                (window, i, render.SDL_RENDERER_ACCELERATED)
             self.assertIsInstance(renderer.contents, render.SDL_Renderer)
             ret = render.SDL_RenderSetViewport(renderer, None)
             self.assertEqual(ret, 0)
         self.assertIsInstance(window.contents, video.SDL_Window)
 
         for i in range(render.SDL_GetNumRenderDrivers()):
-            renderer = render.SDL_CreateRenderer(window, i,
-                                                 render.SDL_RENDERER_ACCELERATED)
+            renderer = render.SDL_CreateRenderer \
+                (window, i, render.SDL_RENDERER_ACCELERATED)
             self.assertIsInstance(renderer.contents, render.SDL_Renderer)
 
             colors = ((16, 22, 185, 217),
                 ret = render.SDL_SetRenderDrawColor(renderer, r, g, b, a)
                 self.assertEqual(ret, 0)
                 dr, dg, db, da = Uint8(), Uint8(), Uint8(), Uint8()
-                ret = render.SDL_GetRenderDrawColor(renderer, byref(dr), byref(dg), byref(db), byref(da))
+                ret = render.SDL_GetRenderDrawColor(renderer, byref(dr),
+                                                    byref(dg), byref(db),
+                                                    byref(da))
                 self.assertEqual(ret, 0)
-                self.assertEqual((dr.value, dg.value, db.value, da.value), (r, g, b, a))
+                self.assertEqual((dr.value, dg.value, db.value, da.value),
+                                 (r, g, b, a))
             render.SDL_DestroyRenderer(renderer)
             #self.assertRaises(sdl.SDLError, render.SDL_SetRenderDrawColor,
             #                  renderer, 10, 20, 30, 40)
         self.assertIsInstance(window.contents, video.SDL_Window)
 
         for i in range(render.SDL_GetNumRenderDrivers()):
-            renderer = render.SDL_CreateRenderer(window, i,
-                                                 render.SDL_RENDERER_ACCELERATED)
+            renderer = render.SDL_CreateRenderer \
+                (window, i, render.SDL_RENDERER_ACCELERATED)
             self.assertIsInstance(renderer.contents, render.SDL_Renderer)
 
             modes = (blendmode.SDL_BLENDMODE_NONE,

sdl2/test/rwops_test.py

     byteify = lambda x, enc: x.encode(enc)
     stringify = lambda x, enc: str(x)
 
+testfile = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                        "resources", "rwopstest.txt")
+
+
 # TODO: extended checks for r/w operations outside of buffer ranges, invalid
 # values, etc.!
 class SDLRWopsTest(unittest.TestCase):
     __tags__ = ["sdl"]
 
-    def setUp(self):
-        self.testfile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "rwopstest.txt")
-
-    def tearDown(self):
-        pass
-
     def test_SDL_RWops(self):
         rw = rwops.SDL_RWops()
         self.assertIsInstance(rw, rwops.SDL_RWops)
 
     def test_SDL_RWFromFile(self):
-        rw = rwops.SDL_RWFromFile(self.testfile.encode("utf-8"), b"r")
+        rw = rwops.SDL_RWFromFile(testfile.encode("utf-8"), b"r")
         self.assertIsInstance(rw.contents, rwops.SDL_RWops)
         # Read the first 36 bytes(sic!). It should be:
         # 'This is a test file for sdl2.rwops!'

sdl2/test/sdl2ext_color_test.py

 
 def color_combos():
     for x in all_combos:
-        yield color.Color(*x)
+        yield Color(*x)
 
 
 def hex_combos():
     __tags__ = ["sdl2ext"]
 
     def test_Color(self):
-        c = color.Color(10, 20, 30, 40)
+        c = Color(10, 20, 30, 40)
         self.assertEqual(c.r, 10)
         self.assertEqual(c.g, 20)
         self.assertEqual(c.b, 30)
         self.assertEqual(c.a, 40)
 
-        self.assertRaises(ValueError, color.Color, 257, 10, 105, 44)
-        self.assertRaises(ValueError, color.Color, 10, 257, 105, 44)
-        self.assertRaises(ValueError, color.Color, 10, 105, 257, 44)
-        self.assertRaises(ValueError, color.Color, 10, 105, 44, 257)
+        self.assertRaises(ValueError, Color, 257, 10, 105, 44)
+        self.assertRaises(ValueError, Color, 10, 257, 105, 44)
+        self.assertRaises(ValueError, Color, 10, 105, 257, 44)
+        self.assertRaises(ValueError, Color, 10, 105, 44, 257)
 
     def test_Color__copy__(self):
         copy_copy = copy.copy
             assertNotEqual(c, c2)
 
     def test_Color__eq__(self):
-        self.assertTrue(color.Color(255, 0, 0, 0) == color.Color(255, 0, 0, 0))
-        self.assertTrue(color.Color(0, 255, 0, 0) == color.Color(0, 255, 0, 0))
-        self.assertTrue(color.Color(0, 0, 255, 0) == color.Color(0, 0, 255, 0))
-        self.assertTrue(color.Color(0, 0, 0, 255) == color.Color(0, 0, 0, 255))
+        self.assertTrue(Color(255, 0, 0, 0) == Color(255, 0, 0, 0))
+        self.assertTrue(Color(0, 255, 0, 0) == Color(0, 255, 0, 0))
+        self.assertTrue(Color(0, 0, 255, 0) == Color(0, 0, 255, 0))
+        self.assertTrue(Color(0, 0, 0, 255) == Color(0, 0, 0, 255))
 
-        self.assertFalse(color.Color(0, 0, 0, 0) == color.Color(255, 0, 0, 0))
-        self.assertFalse(color.Color(0, 0, 0, 0) == color.Color(0, 255, 0, 0))
-        self.assertFalse(color.Color(0, 0, 0, 0) == color.Color(0, 0, 255, 0))
-        self.assertFalse(color.Color(0, 0, 0, 0) == color.Color(0, 0, 0, 255))
+        self.assertFalse(Color(0, 0, 0, 0) == Color(255, 0, 0, 0))
+        self.assertFalse(Color(0, 0, 0, 0) == Color(0, 255, 0, 0))
+        self.assertFalse(Color(0, 0, 0, 0) == Color(0, 0, 255, 0))
+        self.assertFalse(Color(0, 0, 0, 0) == Color(0, 0, 0, 255))
 
-        self.assertTrue(tuple(color.Color(255, 0, 0, 0)) == (255, 0, 0, 0))
-        self.assertTrue(tuple(color.Color(0, 255, 0, 0)) == (0, 255, 0, 0))
-        self.assertTrue(tuple(color.Color(0, 0, 255, 0)) == (0, 0, 255, 0))
-        self.assertTrue(tuple(color.Color(0, 0, 0, 255)) == (0, 0, 0, 255))
+        self.assertTrue(tuple(Color(255, 0, 0, 0)) == (255, 0, 0, 0))
+        self.assertTrue(tuple(Color(0, 255, 0, 0)) == (0, 255, 0, 0))
+        self.assertTrue(tuple(Color(0, 0, 255, 0)) == (0, 0, 255, 0))
+        self.assertTrue(tuple(Color(0, 0, 0, 255)) == (0, 0, 0, 255))
 
-        self.assertFalse(tuple(color.Color(0, 0, 0, 0)) == (255, 0, 0, 0))
-        self.assertFalse(tuple(color.Color(0, 0, 0, 0)) == (0, 255, 0, 0))
-        self.assertFalse(tuple(color.Color(0, 0, 0, 0)) == (0, 0, 255, 0))
-        self.assertFalse(tuple(color.Color(0, 0, 0, 0)) == (0, 0, 0, 255))
+        self.assertFalse(tuple(Color(0, 0, 0, 0)) == (255, 0, 0, 0))
+        self.assertFalse(tuple(Color(0, 0, 0, 0)) == (0, 255, 0, 0))
+        self.assertFalse(tuple(Color(0, 0, 0, 0)) == (0, 0, 255, 0))
+        self.assertFalse(tuple(Color(0, 0, 0, 0)) == (0, 0, 0, 255))
 
-        self.assertTrue(int(color.Color(255, 0, 0, 0)) == 0xff000000)
-        self.assertTrue(int(color.Color(0, 255, 0, 0)) == 0x00ff0000)
-        self.assertTrue(int(color.Color(0, 0, 255, 0)) == 0x0000ff00)
-        self.assertTrue(int(color.Color(0, 0, 0, 255)) == 0x000000ff)
+        self.assertTrue(int(Color(255, 0, 0, 0)) == 0xff000000)
+        self.assertTrue(int(Color(0, 255, 0, 0)) == 0x00ff0000)
+        self.assertTrue(int(Color(0, 0, 255, 0)) == 0x0000ff00)
+        self.assertTrue(int(Color(0, 0, 0, 255)) == 0x000000ff)
 
-        self.assertFalse(int(color.Color(0, 0, 0, 0)) == 0xff000000)
-        self.assertFalse(int(color.Color(0, 0, 0, 0)) == 0x00ff0000)
-        self.assertFalse(int(color.Color(0, 0, 0, 0)) == 0x0000ff00)
-        self.assertFalse(int(color.Color(0, 0, 0, 0)) == 0x000000ff)
+        self.assertFalse(int(Color(0, 0, 0, 0)) == 0xff000000)
+        self.assertFalse(int(Color(0, 0, 0, 0)) == 0x00ff0000)
+        self.assertFalse(int(Color(0, 0, 0, 0)) == 0x0000ff00)
+        self.assertFalse(int(Color(0, 0, 0, 0)) == 0x000000ff)
 
     def test_Color__ne__(self):
-        self.assertTrue(color.Color(0, 0, 0, 0) != color.Color(255, 0, 0, 0))
-        self.assertTrue(color.Color(0, 0, 0, 0) != color.Color(0, 255, 0, 0))
-        self.assertTrue(color.Color(0, 0, 0, 0) != color.Color(0, 0, 255, 0))
-        self.assertTrue(color.Color(0, 0, 0, 0) != color.Color(0, 0, 0, 255))
+        self.assertTrue(Color(0, 0, 0, 0) != Color(255, 0, 0, 0))
+        self.assertTrue(Color(0, 0, 0, 0) != Color(0, 255, 0, 0))
+        self.assertTrue(Color(0, 0, 0, 0) != Color(0, 0, 255, 0))
+        self.assertTrue(Color(0, 0, 0, 0) != Color(0, 0, 0, 255))
 
-        self.assertFalse(color.Color(255, 0, 0, 0) != color.Color(255, 0, 0, 0))
-        self.assertFalse(color.Color(0, 255, 0, 0) != color.Color(0, 255, 0, 0))
-        self.assertFalse(color.Color(0, 0, 255, 0) != color.Color(0, 0, 255, 0))
-        self.assertFalse(color.Color(0, 0, 0, 255) != color.Color(0, 0, 0, 255))
+        self.assertFalse(Color(255, 0, 0, 0) != Color(255, 0, 0, 0))
+        self.assertFalse(Color(0, 255, 0, 0) != Color(0, 255, 0, 0))
+        self.assertFalse(Color(0, 0, 255, 0) != Color(0, 0, 255, 0))
+        self.assertFalse(Color(0, 0, 0, 255) != Color(0, 0, 0, 255))
 
-        self.assertTrue(tuple(color.Color(0, 0, 0, 0)) != (255, 0, 0, 0))
-        self.assertTrue(tuple(color.Color(0, 0, 0, 0)) != (0, 255, 0, 0))
-        self.assertTrue(tuple(color.Color(0, 0, 0, 0)) != (0, 0, 255, 0))
-        self.assertTrue(tuple(color.Color(0, 0, 0, 0)) != (0, 0, 0, 255))
+        self.assertTrue(tuple(Color(0, 0, 0, 0)) != (255, 0, 0, 0))
+        self.assertTrue(tuple(Color(0, 0, 0, 0)) != (0, 255, 0, 0))
+        self.assertTrue(tuple(Color(0, 0, 0, 0)) != (0, 0, 255, 0))
+        self.assertTrue(tuple(Color(0, 0, 0, 0)) != (0, 0, 0, 255))
 
-        self.assertFalse(tuple(color.Color(255, 0, 0, 0)) != (255, 0, 0, 0))
-        self.assertFalse(tuple(color.Color(0, 255, 0, 0)) != (0, 255, 0, 0))
-        self.assertFalse(tuple(color.Color(0, 0, 255, 0)) != (0, 0, 255, 0))
-        self.assertFalse(tuple(color.Color(0, 0, 0, 255)) != (0, 0, 0, 255))
+        self.assertFalse(tuple(Color(255, 0, 0, 0)) != (255, 0, 0, 0))
+        self.assertFalse(tuple(Color(0, 255, 0, 0)) != (0, 255, 0, 0))
+        self.assertFalse(tuple(Color(0, 0, 255, 0)) != (0, 0, 255, 0))
+        self.assertFalse(tuple(Color(0, 0, 0, 255)) != (0, 0, 0, 255))
 
-        self.assertTrue(int(color.Color(0, 0, 0, 0)) != 0xff000000)
-        self.assertTrue(int(color.Color(0, 0, 0, 0)) != 0x00ff0000)
-        self.assertTrue(int(color.Color(0, 0, 0, 0)) != 0x0000ff00)
-        self.assertTrue(int(color.Color(0, 0, 0, 0)) != 0x000000ff)
+        self.assertTrue(int(Color(0, 0, 0, 0)) != 0xff000000)
+        self.assertTrue(int(Color(0, 0, 0, 0)) != 0x00ff0000)
+        self.assertTrue(int(Color(0, 0, 0, 0)) != 0x0000ff00)
+        self.assertTrue(int(Color(0, 0, 0, 0)) != 0x000000ff)
 
-        self.assertFalse(int(color.Color(255, 0, 0, 0)) != 0xff000000)
-        self.assertFalse(int(color.Color(0, 255, 0, 0)) != 0x00ff0000)
-        self.assertFalse(int(color.Color(0, 0, 255, 0)) != 0x0000ff00)
-        self.assertFalse(int(color.Color(0, 0, 0, 255)) != 0x000000ff)
+        self.assertFalse(int(Color(255, 0, 0, 0)) != 0xff000000)
+        self.assertFalse(int(Color(0, 255, 0, 0)) != 0x00ff0000)
+        self.assertFalse(int(Color(0, 0, 255, 0)) != 0x0000ff00)
+        self.assertFalse(int(Color(0, 0, 0, 255)) != 0x000000ff)
 
     def test_Color__repr__(self):
-        c = color.Color(68, 38, 26, 69)
+        c = Color(68, 38, 26, 69)
         c1 = eval(repr(c))
         self.assertEqual(c, c1)
 
     def test_Color__int__(self):
-        c = color.Color(0x00, 0xCC, 0x00, 0xCC)
+        c = Color(0x00, 0xCC, 0x00, 0xCC)
         self.assertEqual(c.r, 0x00)
         self.assertEqual(c.g, 0xCC)
         self.assertEqual(c.b, 0x00)
         self.assertEqual(c.a, 0xCC)
         self.assertEqual(int(c), int(0x00CC00CC))
 
-        c = color.Color(0x72, 0x75, 0x92, 0x33)
+        c = Color(0x72, 0x75, 0x92, 0x33)
         self.assertEqual(c.r, 0x72)
         self.assertEqual(c.g, 0x75)
         self.assertEqual(c.b, 0x92)
         self.assertEqual(int(c), int(0x72759233))
 
     def test_Color__long__(self):
-        c = color.Color(0x00, 0xCC, 0x00, 0xCC)
+        c = Color(0x00, 0xCC, 0x00, 0xCC)
         self.assertEqual(c.r, 0x00)
         self.assertEqual(c.g, 0xCC)
         self.assertEqual(c.b, 0x00)
         self.assertEqual(c.a, 0xCC)
         self.assertEqual(long(c), long(0x00CC00CC))
 
-        c = color.Color(0x72, 0x75, 0x92, 0x33)
+        c = Color(0x72, 0x75, 0x92, 0x33)
         self.assertEqual(c.r, 0x72)
         self.assertEqual(c.g, 0x75)
         self.assertEqual(c.b, 0x92)
         self.assertEqual(long(c), long(0x72759233))
 
     def test_Color__float__(self):
-        c = color.Color(0x00, 0xCC, 0x00, 0xCC)
+        c = Color(0x00, 0xCC, 0x00, 0xCC)
         self.assertEqual(c.r, 0x00)
         self.assertEqual(c.g, 0xCC)
         self.assertEqual(c.b, 0x00)
         self.assertEqual(c.a, 0xCC)
         self.assertEqual(float(c), float(0x00CC00CC))
 
-        c = color.Color(0x72, 0x75, 0x92, 0x33)
+        c = Color(0x72, 0x75, 0x92, 0x33)
         self.assertEqual(c.r, 0x72)
         self.assertEqual(c.g, 0x75)
         self.assertEqual(c.b, 0x92)
         self.assertEqual(float(c), float(0x72759233))
 
     def test_Color__oct__(self):
-        c = color.Color(0x00, 0xCC, 0x00, 0xCC)
+        c = Color(0x00, 0xCC, 0x00, 0xCC)
         self.assertEqual(c.r, 0x00)
         self.assertEqual(c.g, 0xCC)
         self.assertEqual(c.b, 0x00)
         self.assertEqual(c.a, 0xCC)
         self.assertEqual(oct(c), oct(0x00CC00CC))
 
-        c = color.Color(0x72, 0x75, 0x92, 0x33)
+        c = Color(0x72, 0x75, 0x92, 0x33)
         self.assertEqual(c.r, 0x72)
         self.assertEqual(c.g, 0x75)
         self.assertEqual(c.b, 0x92)
         self.assertEqual(oct(c), oct(0x72759233))
 
     def test_Color__hex__(self):
-        c = color.Color(0x00, 0xCC, 0x00, 0xCC)
+        c = Color(0x00, 0xCC, 0x00, 0xCC)
         self.assertEqual(c.r, 0x00)
         self.assertEqual(c.g, 0xCC)
         self.assertEqual(c.b, 0x00)
         self.assertEqual(c.a, 0xCC)
         self.assertEqual(hex(c), hex(0x00CC00CC))
 
-        c = color.Color(0x72, 0x75, 0x92, 0x33)
+        c = Color(0x72, 0x75, 0x92, 0x33)
         self.assertEqual(c.r, 0x72)
         self.assertEqual(c.g, 0x75)
         self.assertEqual(c.b, 0x92)
         self.assertEqual(hex(c), hex(0x72759233))
 
     def test_Color__invert__(self):
-        self.assertEqual(~color.Color(), color.Color(0, 0, 0, 0))
-        self.assertEqual(~color.Color(0, 0, 0, 0), color.Color(255, 255, 255, 255))
-        self.assertEqual(~color.Color(255, 0, 0, 0), color.Color(0, 255, 255, 255))
-        self.assertEqual(~color.Color(0, 255, 0, 0), color.Color(255, 0, 255, 255))
-        self.assertEqual(~color.Color(0, 0, 255, 0), color.Color(255, 255, 0, 255))
-        self.assertEqual(~color.Color(0, 0, 0, 255), color.Color(255, 255, 255, 0))
-        self.assertEqual(~color.Color(127, 127, 127, 0), color.Color(128, 128, 128, 255))
+        self.assertEqual(~Color(), Color(0, 0, 0, 0))
+        self.assertEqual(~Color(0, 0, 0, 0), Color(255, 255, 255, 255))
+        self.assertEqual(~Color(255, 0, 0, 0), Color(0, 255, 255, 255))
+        self.assertEqual(~Color(0, 255, 0, 0), Color(255, 0, 255, 255))
+        self.assertEqual(~Color(0, 0, 255, 0), Color(255, 255, 0, 255))
+        self.assertEqual(~Color(0, 0, 0, 255), Color(255, 255, 255, 0))
+        self.assertEqual(~Color(127, 127, 127, 0), Color(128, 128, 128, 255))
 
-        self.assertEqual(~color.Color(1, 2, 3, 4), color.Color(254, 253, 252, 251))
-        self.assertEqual(~color.Color(127, 127, 127, 0), color.Color(128, 128, 128, 255))
+        self.assertEqual(~Color(1, 2, 3, 4), Color(254, 253, 252, 251))
+        self.assertEqual(~Color(127, 127, 127, 0), Color(128, 128, 128, 255))
 
     def test_Color__mod__(self):
-        c1 = color.Color()
+        c1 = Color()
         self.assertEqual(c1.r, 255)
         self.assertEqual(c1.g, 255)
         self.assertEqual(c1.b, 255)
         self.assertEqual(c1.a, 255)
 
-        c2 = color.Color(2, 4, 8, 16)
+        c2 = Color(2, 4, 8, 16)
         self.assertEqual(c2.r, 2)
         self.assertEqual(c2.g, 4)
         self.assertEqual(c2.b, 8)
         self.assertEqual(c3.a, 15)
 
     def test_Color__div__(self):
-        c1 = color.Color(128, 128, 128, 128)
+        c1 = Color(128, 128, 128, 128)
         self.assertEqual(c1.r, 128)
         self.assertEqual(c1.g, 128)
         self.assertEqual(c1.b, 128)
         self.assertEqual(c1.a, 128)
 
-        c2 = color.Color(2, 4, 8, 16)
+        c2 = Color(2, 4, 8, 16)
         self.assertEqual(c2.r, 2)
         self.assertEqual(c2.g, 4)
         self.assertEqual(c2.b, 8)
         self.assertEqual(c3.a, 0)
 
     def test_Color__mul__(self):
-        c1 = color.Color(1, 1, 1, 1)
+        c1 = Color(1, 1, 1, 1)
         self.assertEqual(c1.r, 1)
         self.assertEqual(c1.g, 1)
         self.assertEqual(c1.b, 1)
         self.assertEqual(c1.a, 1)
 
-        c2 = color.Color(2, 5, 3, 22)
+        c2 = Color(2, 5, 3, 22)
         self.assertEqual(c2.r, 2)
         self.assertEqual(c2.g, 5)
         self.assertEqual(c2.b, 3)
         self.assertEqual(c3.a, 255)
 
     def test_Color__sub__(self):
-        c1 = color.Color(255, 255, 255, 255)
+        c1 = Color(255, 255, 255, 255)
         self.assertEqual(c1.r, 255)
         self.assertEqual(c1.g, 255)
         self.assertEqual(c1.b, 255)
         self.assertEqual(c1.a, 255)
 
-        c2 = color.Color(20, 33, 82, 193)
+        c2 = Color(20, 33, 82, 193)
         self.assertEqual(c2.r, 20)
         self.assertEqual(c2.g, 33)
         self.assertEqual(c2.b, 82)
         self.assertEqual(c3.a, 0)
 
     def test_Color__add__(self):
-        c1 = color.Color(0, 0, 0, 0)
+        c1 = Color(0, 0, 0, 0)
         self.assertEqual(c1.r, 0)
         self.assertEqual(c1.g, 0)
         self.assertEqual(c1.b, 0)
         self.assertEqual(c1.a, 0)
 
-        c2 = color.Color(20, 33, 82, 193)
+        c2 = Color(20, 33, 82, 193)
         self.assertEqual(c2.r, 20)
         self.assertEqual(c2.g, 33)
         self.assertEqual(c2.b, 82)
         self.assertEqual(c3.a, 255)
 
     def test_Color__len__(self):
-        c = color.Color(204, 38, 194, 55)
+        c = Color(204, 38, 194, 55)
         self.assertEqual(len(c), 4)
-        self.assertEqual(len(color.Color()), 4)
-        self.assertEqual(len(color.Color(2)), 4)
+        self.assertEqual(len(Color()), 4)
+        self.assertEqual(len(Color(2)), 4)
 
     def test_Color__getitem__(self):
-        c = color.Color(204, 38, 194, 55)
+        c = Color(204, 38, 194, 55)
         self.assertEqual(c[0], 204)
         self.assertEqual(c[1], 38)
         self.assertEqual(c[2], 194)
         self.assertEqual(c[3], 55)
 
     def test_Color__setitem(self):
-        c = color.Color(204, 38, 194, 55)
+        c = Color(204, 38, 194, 55)
         self.assertEqual(c[0], 204)
         self.assertEqual(c[1], 38)
         self.assertEqual(c[2], 194)
         self.assertEqual(c[2], 173)
 
     def test_Color_r(self):
-        c = color.Color(100, 100, 100)
+        c = Color(100, 100, 100)
         self.assertEqual(c.r, 100)
 
-        c = color.Color(100, 100, 100, 100)
+        c = Color(100, 100, 100, 100)
         self.assertEqual(c.r, 100)
 
-        c = color.Color(100, 100, 100)
+        c = Color(100, 100, 100)
         self.assertEqual(c.r, 100)
         c.r = 200
         self.assertEqual(c.r, 200)
         self.assertEqual(c.r, 222)
 
     def test_Color_g(self):
-        c = color.Color(100, 100, 100)
+        c = Color(100, 100, 100)
         self.assertEqual(c.g, 100)
 
-        c = color.Color(100, 100, 100, 100)
+        c = Color(100, 100, 100, 100)
         self.assertEqual(c.g, 100)
 
-        c = color.Color(100, 100, 100)
+        c = Color(100, 100, 100)
         self.assertEqual(c.g, 100)
         c.g = 200
         self.assertEqual(c.g, 200)
         self.assertEqual(c.g, 222)
 
     def test_Color_b(self):
-        c = color.Color(100, 100, 100)
+        c = Color(100, 100, 100)
         self.assertEqual(c.b, 100)
 
-        c = color.Color(100, 100, 100, 100)
+        c = Color(100, 100, 100, 100)
         self.assertEqual(c.b, 100)
 
-        c = color.Color(100, 100, 100)
+        c = Color(100, 100, 100)
         self.assertEqual(c.b, 100)
         c.b = 200
         self.assertEqual(c.b, 200)
         self.assertEqual(c.b, 222)
 
     def test_Color_a(self):
-        c = color.Color(100, 100, 100)
+        c = Color(100, 100, 100)
         self.assertEqual(c.a, 255)
 
-        c = color.Color(100, 100, 100, 100)
+        c = Color(100, 100, 100, 100)
         self.assertEqual(c.a, 100)
 
-        c = color.Color(100, 100, 100)
+        c = Color(100, 100, 100)
         self.assertEqual(c.a, 255)
         c.a = 200
         self.assertEqual(c.a, 200)
         self.assertEqual(c.a, 222)
 
     def test_Color_rgba(self):
-        c = color.Color(0)
+        c = Color(0)
         self.assertEqual(c.r, 0)
         self.assertEqual(c.g, 255)
         self.assertEqual(c.b, 255)
             assertTrue(0 <= a <= 100)
 
             for cx in [(0, 0, 0, 0), (255, 255, 255, 255)]:
-                c2 = color.Color(*cx)
+                c2 = Color(*cx)
                 assertEqual(tuple(c2), cx)
 
                 c2.hsva = c.hsva
             assertTrue(0 <= a <= 100)
 
             for cx in [(0, 0, 0, 0), (255, 255, 255, 255)]:
-                c2 = color.Color(*cx)
+                c2 = Color(*cx)
                 assertEqual(tuple(c2), cx)
 
                 c2.hsla = c.hsla
             assertTrue(-0.5 <= i3 <= 0.5)
 
             for cx in [(0, 0, 0, 0), (255, 255, 255, 255)]:
-                c2 = color.Color(*cx)
+                c2 = Color(*cx)
                 assertEqual(tuple(c2), cx)
 
                 c2.i1i2i3 = c.i1i2i3
             assertTrue(0 <= y <= 1)
 
             for cx in [(0, 0, 0, 0), (255, 255, 255, 255)]:
-                c2 = color.Color(*cx)
+                c2 = Color(*cx)
                 assertEqual(tuple(c2), cx)
 
                 c2.cmy = val.cmy
                     "Failed for color '%s' and cx '%s': %s" % (val, cx, c2))
 
     def test_Color_normalize(self):
-        c = color.Color(204, 38, 194, 55)
+        c = Color(204, 38, 194, 55)
         self.assertEqual(c.r, 204)
         self.assertEqual(c.g, 38)
         self.assertEqual(c.b, 194)
         self.assertAlmostEquals(t[2], 0.760784, places=5)
         self.assertAlmostEquals(t[3], 0.215686, places=5)
 
-        c = color.Color(255, 255, 255, 255)
+        c = Color(255, 255, 255, 255)
         self.assertEqual(c.normalize(), (1.0, 1.0, 1.0, 1.0))
-        c = color.Color(0, 0, 0, 0)
+        c = Color(0, 0, 0, 0)
         self.assertEqual(c.normalize(), (0.0, 0.0, 0.0, 0.0))
-        c = color.Color(128, 128, 128, 128)
+        c = Color(128, 128, 128, 128)
         t = c.normalize()
         for v in t:
             self.assertAlmostEquals(v, 0.5, places=2)
 
-        c = color.Color(128, 255, 0, 52)
+        c = Color(128, 255, 0, 52)
         t = c.normalize()
         self.assertAlmostEquals(t[0], 0.5, places=2)
         self.assertEqual(t[1], 1.0)
     def test_string_to_color(self):
         assertEqual = self.assertEqual
         assertRaises = self.assertRaises
-        for method in(color.string_to_color, color.convert_to_color, color.COLOR):
+        for method in(color.string_to_color, color.convert_to_color,
+                      color.COLOR):
             assertEqual(method('#00000000').r, 0x00)
             assertEqual(method('#10000000').r, 0x10)
             assertEqual(method('#20000000').r, 0x20)
                 assertEqual(method(val), cvals[index], "Failed for '%s'" % val)
 
         self.assertRaises(TypeError, color.string_to_color, 0xff000000)
-        self.assertRaises(TypeError, color.string_to_color, color.Color())
+        self.assertRaises(TypeError, color.string_to_color, Color())
 
     def test_convert_to_color(self):
         self.assertEqual(color.COLOR, color.convert_to_color)
 
         assertEqual = self.assertEqual
         for index, val in enumerate(hex_combos()):
-            assertEqual(color.COLOR(val), cvals[index], "Failed for '%s'" % val)
+            assertEqual(color.COLOR(val), cvals[index],
+                        "Failed for '%s'" % val)
 
         for index, val in enumerate(hash_combos()):
-            assertEqual(color.COLOR(val), cvals[index], "Failed for '%s'" % val)
+            assertEqual(color.COLOR(val), cvals[index],
+                        "Failed for '%s'" % val)
 
         for index, val in enumerate(hex_combos()):
-            assertEqual(color.COLOR(val), cvals[index], "Failed for '%s'" % val)
+            assertEqual(color.COLOR(val), cvals[index],
+                        "Failed for '%s'" % val)
 
         for index, val in enumerate(argb_combos()):
-            assertEqual(color.COLOR(val), cvals[index], "Failed for '0x%.8x'" % val)
+            assertEqual(color.COLOR(val), cvals[index],
+                        "Failed for '0x%.8x'" % val)
 
         for index, val in enumerate(color_combos()):
-            assertEqual(color.COLOR(val), cvals[index], "Failed for '%s'" % val)
+            assertEqual(color.COLOR(val), cvals[index],
+                        "Failed for '%s'" % val)
 
         self.assertRaises(ValueError, color.convert_to_color, self)
         self.assertRaises(ValueError, color.convert_to_color, "Test")
 
+
 if __name__ == '__main__':
     sys.exit(unittest.main())

sdl2/test/sdl2ext_ebs_test.py

     def __eq__(self, other):
         return self.x == other.x and self.y == other.y
 
+
 class Movement(object):
     def __init__(self, vx=0, vy=0):
         self.vx = vx
         class SimpleSystem(object):
             def __init__(self):
                 self.componenttypes = (Position,)
+
             def process(self, world, components):
                 pass
 

sdl2/test/sdl2ext_events_test.py

     # Does nothing
     pass
 
+
 class SDL2ExtEventsTest(unittest.TestCase):
     __tags__ = ["sdl2ext"]
 
     @unittest.skipIf(not _HASMP, "multiprocessing is not supported")
     def test_MPEventHandler(self):
         self.assertRaises(TypeError, events.MPEventHandler)
-        self.assertIsInstance(events.MPEventHandler(None), events.MPEventHandler)
-        self.assertIsInstance(events.MPEventHandler(132), events.MPEventHandler)
-        self.assertIsInstance(events.MPEventHandler("Test"), events.MPEventHandler)
+        self.assertIsInstance(events.MPEventHandler(None),
+                              events.MPEventHandler)
+        self.assertIsInstance(events.MPEventHandler(132),
+                              events.MPEventHandler)
+        self.assertIsInstance(events.MPEventHandler("Test"),
+                              events.MPEventHandler)
 
         ev = events.MPEventHandler(None)
         self.assertEqual(ev.sender, None)

sdl2/test/sdl2ext_font_test.py

         sdl2ext.quit()
 
     def test_BitmapFont(self):
-        sf = surface.SDL_LoadBMP(byteify(RESOURCES.get_path("font.bmp"), "utf-8"))
+        sf = surface.SDL_LoadBMP(byteify(RESOURCES.get_path("font.bmp"),
+                                         "utf-8"))
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         font = sdl2ext.BitmapFont(sf, (32, 32), FONTMAP)
         self.assertIsInstance(font, sdl2ext.BitmapFont)
     def test_BitmapFont_can_render(self):
         pass
 
+
 if __name__ == '__main__':
     sys.exit(unittest.main())

sdl2/test/sdl2ext_image_test.py

 
 RESOURCES = sdl2ext.Resources(__file__, "resources")
 
-formats = [#"bmp",  # Do not use bmp - it's contained in resources.zip
+formats = [  # Do not use bmp - it's contained in resources.zip
            "cur",
            "gif",
            "ico",

sdl2/test/sdl2ext_particles_test.py

                 self.assertEqual(p.y, y)
 
     def test_Particle_life(self):
-        for life in range (-100, 100):
+        for life in range(-100, 100):
             p = particles.Particle(0, 0, life)
             self.assertEqual(p.life, life)
 
         self.assertRaises(TypeError, setf, engine, "Test")
         self.assertRaises(TypeError, setf, engine, 1234)
 
-
     def test_ParticleEngine_deletefunc(self):
         def func(w, c):
             pass

sdl2/test/sdl2ext_pixelaccess_test.py

 except:
     _HASNUMPY = False
 
+
 class SDL2ExtPixelAccessTest(unittest.TestCase):
     __tags__ = ["sdl", "sdl2ext"]
 
         sdl2ext.fill(sprite, 0xAABBCCDD, (2, 2, 2, 2))
         nparray = sdl2ext.pixels2d(sprite)
 
-
     @unittest.skipIf(not _HASNUMPY, "numpy module is not supported")
     def test_pixels3d(self):
         factory = sdl2ext.SpriteFactory(sdl2ext.SOFTWARE)

sdl2/test/sdl2ext_sprite_test.py

                     sprite = factory.create_software_sprite((w, h), bpp)
                     self.assertIsInstance(sprite, sdl2ext.SoftwareSprite)
 
-        #self.assertRaises(ValueError, factory.create_software_sprite, (-1, -1))
-        #self.assertRaises(ValueError, factory.create_software_sprite, (-10, 5))
-        #self.assertRaises(ValueError, factory.create_software_sprite, (10, -5))
+        #self.assertRaises(ValueError, factory.create_software_sprite, (-1,-1))
+        #self.assertRaises(ValueError, factory.create_software_sprite, (-10,5))
+        #self.assertRaises(ValueError, factory.create_software_sprite, (10,-5))
         self.assertRaises(TypeError, factory.create_software_sprite, size=None)
-        self.assertRaises(sdl2ext.SDLError, factory.create_software_sprite, bpp= -1)
+        self.assertRaises(sdl2ext.SDLError, factory.create_software_sprite,
+                          bpp=-1)
         self.assertRaises(TypeError, factory.create_software_sprite, masks=5)
         self.assertRaises((ArgumentError, TypeError),
                           factory.create_software_sprite,
         SDL_FreeSurface(sf)
 
         for factory in (tfactory, sfactory):
-            self.assertRaises((sdl2ext.SDLError, AttributeError, ArgumentError, TypeError),
-                              factory.from_surface, None)
+            self.assertRaises((sdl2ext.SDLError, AttributeError, ArgumentError,
+                               TypeError), factory.from_surface, None)
             self.assertRaises((AttributeError, ArgumentError, TypeError),
                               factory.from_surface, "test")
             # TODO: crashes pypy 2.0
         sf = SDL_CreateRGBSurface(0, 10, 10, 32, 0, 0, 0, 0)
         sprite = sdl2ext.SoftwareSprite(sf.contents, True)
         self.assertEqual(sprite.area, (0, 0, 10, 10))
+
         def setarea(s, v):
             s.area = v
         self.assertRaises(AttributeError, setarea, sprite, (1, 2, 3, 4))

sdl2/test/sdlimage_test.py

            #"xv",
            ]
 
+
 class SDLImageTest(unittest.TestCase):
     __tags__ = ["sdl", "sdlimage"]
 
             filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                     "resources", fname % fmt)
             fp = open(filename, "rb")
-            tex = sdlimage.IMG_LoadTexture_RW(rd, rwops.rw_from_object(fp), False)
+            tex = sdlimage.IMG_LoadTexture_RW(rd, rwops.rw_from_object(fp), 0)
             fp.close()
             self.assertIsInstance(tex.contents, render.SDL_Texture)
             render.SDL_DestroyTexture(tex)
             filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                     "resources", fname % fmt)
             fp = open(filename, "rb")
-            tex = sdlimage.IMG_LoadTextureTyped_RW(rd, rwops.rw_from_object(fp),
-                                                   False, fmt.upper().encode("utf-8"))
+            fmtx = fmt.upper().encode("utf-8")
+            rw = rwops.rw_from_object(fp)
+            tex = sdlimage.IMG_LoadTextureTyped_RW(rd, rw, 0, fmtx)
             fp.close()
             self.assertIsInstance(tex.contents, render.SDL_Texture)
             render.SDL_DestroyTexture(tex)
             surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadBMP_rw(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.bmp"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.bmp"), "rb")
         sf = sdlimage.IMG_LoadBMP_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadCUR_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.cur"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.cur"), "rb")
         sf = sdlimage.IMG_LoadCUR_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         pass
 
     def test_IMG_LoadGIF_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.gif"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.gif"), "rb")
         sf = sdlimage.IMG_LoadGIF_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadICO_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.ico"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.ico"), "rb")
         sf = sdlimage.IMG_LoadICO_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadJPG_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.jpg"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.jpg"), "rb")
         sf = sdlimage.IMG_LoadJPG_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadLBM_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.lbm"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.lbm"), "rb")
         sf = sdlimage.IMG_LoadLBM_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadPCX_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.pcx"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.pcx"), "rb")
         sf = sdlimage.IMG_LoadPCX_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadPNG_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.png"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.png"), "rb")
         sf = sdlimage.IMG_LoadPNG_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadPNM_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.pnm"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.pnm"), "rb")
         sf = sdlimage.IMG_LoadPNM_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadTGA_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.tga"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.tga"), "rb")
         sf = sdlimage.IMG_LoadTGA_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadTIF_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.tif"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.tif"), "rb")
         sf = sdlimage.IMG_LoadTIF_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadWEBP_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.webp"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.webp"), "rb")
         sf = sdlimage.IMG_LoadWEBP_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadXCF_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.xcf"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.xcf"), "rb")
         sf = sdlimage.IMG_LoadXCF_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
 
     def test_IMG_LoadXPM_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.xpm"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.xpm"), "rb")
         sf = sdlimage.IMG_LoadXPM_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
 
     @unittest.skip("not implemented")
     def test_IMG_LoadXV_RW(self):
-        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "surfacetest.xv"), "rb")
+        fp = open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                               "resources", "surfacetest.xv"), "rb")
         sf = sdlimage.IMG_LoadXV_RW(rwops.rw_from_object(fp))
         fp.close()
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
     def test_IMG_isBMP(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "bmp":
     def test_IMG_isCUR(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                     "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "cur":
     def test_IMG_isGIF(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "gif":
     def test_IMG_isICO(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "ico":
     def test_IMG_isJPG(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "jpg":
     def test_IMG_isLBM(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "lbm":
     def test_IMG_isPCX(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "pcx":
     def test_IMG_isPNG(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "png":
     def test_IMG_isPNM(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt in ("pnm", "pbm", "ppm", "pgm"):
     def test_IMG_isTIF(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "tif":
     def test_IMG_isWEBP(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "webp":
     def test_IMG_isXCF(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")
             imgrw = rwops.rw_from_object(fp)
             if fmt == "xcf":
     def test_IMG_isXPM(self):
         fname = "surfacetest.%s"
         for fmt in formats:
-            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", fname % fmt)
+            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                                    "resources", fname % fmt)
             fp = open(filename, "rb")