[pypy-svn] r23716 - pypy/dist/pypy/rpython/rctypes/test

arigo at codespeak.net arigo at codespeak.net
Tue Feb 28 00:59:29 CET 2006


Author: arigo
Date: Tue Feb 28 00:59:12 2006
New Revision: 23716

Modified:
   pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py
Log:
Made the rctypes test pass on Linux (and probably Windows) also with the most
recent rctypes release (0.9.9.3).


Modified: pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py	Tue Feb 28 00:59:12 2006
@@ -47,12 +47,17 @@
         c_long, c_ulong, c_longlong, c_ulonglong, c_float, c_double, \
         POINTER, Structure, byref, ARRAY
 
+# LoadLibrary is deprecated in ctypes, this should be removed at some point
+if "load" in dir(cdll):
+    cdll_load = cdll.load
+else:
+    cdll_load = cdll.LoadLibrary
+
 if sys.platform == 'win32':
-    mylib = cdll.LoadLibrary('msvcrt.dll')
+    mylib = cdll_load('msvcrt.dll')
 elif sys.platform == 'linux2':
-    mylib = cdll.LoadLibrary('libc.so.6')
+    mylib = cdll_load('libc.so.6')
 elif sys.platform == 'darwin':
-    #mylib = cdll.LoadLibrary('c.dylib')
     mylib = cdll.c
 else:
     py.test.skip("don't know how to load the c lib for %s" % 
@@ -76,14 +81,9 @@
 compile_c_module([thisdir.join("_rctypes_test.c")], "_rctypes_test")
 
 if sys.platform == "win32":
-    _rctypes_test = cdll.LoadLibrary("_rctypes_test.pyd")
+    _rctypes_test = cdll_load("_rctypes_test.pyd")
 else:
-    # LoadLibrary is deprecated in ctypes, this should be removed at some 
-    # point
-    if "load" in dir(cdll):
-        _rctypes_test = cdll.load(str(thisdir.join("_rctypes_test.so")))
-    else:
-        _rctypes_test = cdll.LoadLibrary(str(thisdir.join("_rctypes_test.so")))
+    _rctypes_test = cdll_load(str(thisdir.join("_rctypes_test.so")))
 
 # _testfunc_byval
 testfunc_byval = _rctypes_test._testfunc_byval
@@ -280,13 +280,9 @@
 
     def test_simple(self):
         if sys.platform == "win32":
-            dll = cdll.LoadLibrary("_rctypes_test.pyd")
+            dll = cdll_load("_rctypes_test.pyd")
         else:
-            # LoadLibrary is deprecated
-            if "load" in dir(cdll):
-                dll = cdll.load(str(thisdir.join("_rctypes_test.so")))
-            else:
-                dll = cdll.LoadLibrary(str(thisdir.join("_rctypes_test.so")))
+            dll = cdll_load(str(thisdir.join("_rctypes_test.so")))
         in_point = tagpoint()
         in_point.x = 42
         in_point.y = 17



More information about the Pypy-commit mailing list