Author: Amaury Forgeot d'Arc <[email protected]>
Branch: 
Changeset: r910:7f59c7496f07
Date: 2012-09-03 21:49 +0200
http://bitbucket.org/cffi/cffi/changeset/7f59c7496f07/

Log:    Fix tests for CPython 3.3 and 3.2.

diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -25,7 +25,10 @@
     mandatory_b_prefix = 'b'
     mandatory_u_prefix = ''
     readbuf = lambda buf: buf.tobytes()
-    bufchar = ord
+    if sys.version_info < (3, 3):
+        bufchar = lambda x: bytes([ord(x)])
+    else:
+        bufchar = ord
     bytechr = lambda n: bytes([n])
     u = ""
 
@@ -910,7 +913,7 @@
                                        ('j', BInt, -1)])
     BFunc21 = new_function_type((BStruct,), BInt, False)
     f = cast(BFunc21, _testfunc(21))
-    res = f(range(13, 3, -1))
+    res = f(list(range(13, 3, -1)))
     lst = [(n << i) for (i, n) in enumerate(range(13, 3, -1))]
     assert res == sum(lst)
 
@@ -1080,7 +1083,7 @@
                                        ('i', BInt, -1),
                                        ('j', BInt, -1)])
     def cb():
-        return newp(BStructPtr, range(13, 3, -1))[0]
+        return newp(BStructPtr, list(range(13, 3, -1)))[0]
     BFunc = new_function_type((), BStruct)
     f = callback(BFunc, cb)
     s = f()
@@ -1814,11 +1817,12 @@
     c[2] = b'-'
     buf[:2] = b'HI'
     assert string(c) == b'HI-there'
-    assert buf[:4:2] == b'H-'
-    if '__pypy__' not in sys.builtin_module_names:
-        # XXX pypy doesn't support the following assignment so far
-        buf[:4:2] = b'XY'
-        assert string(c) == b'XIYthere'
+    if sys.version_info < (3,) or sys.version_info >= (3, 3):
+        assert buf[:4:2] == b'H-'
+        if '__pypy__' not in sys.builtin_module_names:
+            # XXX pypy doesn't support the following assignment so far
+            buf[:4:2] = b'XY'
+            assert string(c) == b'XIYthere'
 
 def test_getcname():
     BUChar = new_primitive_type("unsigned char")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to