[pypy-svn] r72445 - in pypy/trunk/pypy/module/cpyext: . test

xoraxax at codespeak.net xoraxax at codespeak.net
Sat Mar 20 14:18:16 CET 2010


Author: xoraxax
Date: Sat Mar 20 14:18:15 2010
New Revision: 72445

Added:
   pypy/trunk/pypy/module/cpyext/test/__init__.py
Removed:
   pypy/trunk/pypy/module/cpyext/test/autopath.py
Modified:
   pypy/trunk/pypy/module/cpyext/api.py
   pypy/trunk/pypy/module/cpyext/test/test_floatobject.py
Log:
Fix duplicate code, fix autopath imports.

Modified: pypy/trunk/pypy/module/cpyext/api.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/api.py	(original)
+++ pypy/trunk/pypy/module/cpyext/api.py	Sat Mar 20 14:18:15 2010
@@ -1,7 +1,8 @@
-import py
-import autopath
 import ctypes
 
+import py
+
+from pypy.translator.goal import autopath
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.rpython.tool import rffi_platform
 from pypy.rpython.lltypesystem import ll2ctypes

Added: pypy/trunk/pypy/module/cpyext/test/__init__.py
==============================================================================

Modified: pypy/trunk/pypy/module/cpyext/test/test_floatobject.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/test/test_floatobject.py	(original)
+++ pypy/trunk/pypy/module/cpyext/test/test_floatobject.py	Sat Mar 20 14:18:15 2010
@@ -1,51 +1,9 @@
-from pypy.conftest import gettestobjspace
-from pypy.interpreter.error import OperationError
-from pypy.rpython.lltypesystem import rffi, lltype
-from pypy.translator.tool.cbuild import ExternalCompilationInfo
-from pypy.translator import platform
-from pypy.module.cpyext import api
-from test_cpyext import compile_module
+from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtension
 
-import py, autopath
+import py
 import sys
 
-class AppTestFloatObject:
-    def setup_class(cls):
-        cls.api_library = api.build_bridge(cls.space, rename=True)
-
-    def setup_method(self, func):
-        self.w_import_module = self.space.wrap(self.import_module)
-
-    def teardown_method(self, func):
-        try:
-            self.space.delitem(self.space.sys.get('modules'),
-                               self.space.wrap('foo'))
-        except OperationError:
-            pass
-
-    def import_module(self, name, init, body=''):
-        code = """
-        #include <pypy_rename.h>
-        #include <Python.h>
-        %(body)s
-
-        void init%(name)s(void) {
-        %(init)s
-        }
-        """ % dict(name=name, init=init, body=body)
-        if sys.platform == 'win32':
-            libraries = [self.api_library]
-            mod = compile_module(name, code, libraries=libraries)
-        else:
-            libraries = [str(self.api_library+'.so')]
-            mod = compile_module(name, code, link_files=libraries)
-        import ctypes
-        initfunc = ctypes.CDLL(mod)['init%s' % (name,)]
-        initfunc()
-        return self.space.getitem(
-            self.space.sys.get('modules'),
-            self.space.wrap(name))
-
+class AppTestFloatObject(AppTestCpythonExtension):
     def test_floatobject(self):
         import sys
         init = """



More information about the Pypy-commit mailing list