[pypy-svn] r54847 - pypy/dist/pypy/rlib/rsdl/test

arigo at codespeak.net arigo at codespeak.net
Sat May 17 17:39:09 CEST 2008


Author: arigo
Date: Sat May 17 17:39:08 2008
New Revision: 54847

Modified:
   pypy/dist/pypy/rlib/rsdl/test/test_sdl_image.py
Log:
Speed up test_image_pixels().


Modified: pypy/dist/pypy/rlib/rsdl/test/test_sdl_image.py
==============================================================================
--- pypy/dist/pypy/rlib/rsdl/test/test_sdl_image.py	(original)
+++ pypy/dist/pypy/rlib/rsdl/test/test_sdl_image.py	Sat May 17 17:39:08 2008
@@ -23,7 +23,7 @@
             rgb = lltype.malloc(rffi.CArray(RSDL.Uint8), 3, flavor='raw')
             try:
                 for y in range(23):
-                    for x in range(17):
+                    for x in range(y % 13, 17, 13):
                         color = RSDL.getpixel(image, x, y)
                         RSDL.GetRGB(color,
                                     image.c_format,
@@ -39,13 +39,12 @@
         finally:
             RSDL.UnlockSurface(image)
         RSDL.FreeSurface(image)
-        for y in range(23):
-            for x in range(17):
-                f = (x*17 + y*23) / float(17*17+23*23)
-                expected_r = int(255.0 * (1.0-f))
-                expected_g = 0
-                expected_b = int(255.0 * f)
-                r, g, b = result[x, y]
-                assert abs(r-expected_r) < 10
-                assert abs(g-expected_g) < 10
-                assert abs(b-expected_b) < 10
+        for x, y in result:
+            f = (x*17 + y*23) / float(17*17+23*23)
+            expected_r = int(255.0 * (1.0-f))
+            expected_g = 0
+            expected_b = int(255.0 * f)
+            r, g, b = result[x, y]
+            assert abs(r-expected_r) < 10
+            assert abs(g-expected_g) < 10
+            assert abs(b-expected_b) < 10



More information about the Pypy-commit mailing list