[pypy-commit] pypy reflex-support: adapt to changes in test harness

wlav noreply at buildbot.pypy.org
Thu Dec 6 02:23:36 CET 2012


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r59338:bda95ea0c6c8
Date: 2012-12-05 17:15 -0800
http://bitbucket.org/pypy/pypy/changeset/bda95ea0c6c8/

Log:	adapt to changes in test harness

diff --git a/pypy/module/cppyy/test/test_crossing.py b/pypy/module/cppyy/test/test_crossing.py
--- a/pypy/module/cppyy/test/test_crossing.py
+++ b/pypy/module/cppyy/test/test_crossing.py
@@ -13,7 +13,8 @@
 
 
 class AppTestCrossing(AppTestCpythonExtensionBase):
-    spaceconfig = dict(usemodules=['cpyext', 'cppyy', 'thread', '_rawffi', '_ffi', 'array'])
+    spaceconfig = dict(usemodules=['cpyext', 'cppyy', 'thread', '_rawffi', '_ffi',
+                                   'array', 'itertools', 'rctime', 'binascii'])
 
     def setup_class(cls):
         # following from AppTestCpythonExtensionBase, with cppyy added
@@ -26,15 +27,25 @@
 
         # cppyy specific additions (not that the test_dct is loaded late
         # to allow the generated extension module be loaded first)
-        cls.w_test_dct  = cls.space.wrap(test_dct)
-        cls.w_datatypes = cls.space.appexec([], """():
-            import cppyy, cpyext""")
+        cls.w_test_dct    = cls.space.wrap(test_dct)
+        cls.w_pre_imports = cls.space.appexec([], """():
+            import cppyy, ctypes""")    # prevents leak-checking complaints on ctypes
+        from pypy.module.imp.importing import get_so_extension
+        cls.w_soext = cls.space.wrap(get_so_extension(cls.space))
 
-    def setup_method(self, func):
-        AppTestCpythonExtensionBase.setup_method(self, func)
+    def test00_base_class(self):
+        """Test from cpyext; only here to see whether the imported class works"""
 
-        if hasattr(self, 'cmodule'):
-            return
+        import sys
+        init = """
+        if (Py_IsInitialized())
+            Py_InitModule("foo", NULL);
+        """
+        self.import_module(name='foo', init=init)
+        assert 'foo' in sys.modules
+
+    def test01_build_bar_extension(self):
+        """Test that builds the needed extension; runs as test to keep it loaded"""
 
         import os, ctypes
 
@@ -42,6 +53,7 @@
         if (Py_IsInitialized())
             Py_InitModule("bar", methods);
         """
+        # note: only the symbols are needed for C, none for python
         body = """
         long bar_unwrap(PyObject* arg)
         {
@@ -56,24 +68,11 @@
         };
         """
 
-        modname = self.import_module(name='bar', init=init, body=body, load_it=False)
-        from pypy.module.imp.importing import get_so_extension
-        soext = get_so_extension(self.space)
-        fullmodname = os.path.join(modname, 'bar' + soext)
+        dirname = self.import_module(name='bar', init=init, body=body, load_it=False)
+        fullmodname = os.path.join(dirname, 'bar' + self.soext)
         self.cmodule = ctypes.CDLL(fullmodname, ctypes.RTLD_GLOBAL)
 
-    def test00_base_class(self):
-        """Test from cpyext; only here to see whether the imported class works"""
-
-        import sys
-        init = """
-        if (Py_IsInitialized())
-            Py_InitModule("foo", NULL);
-        """
-        self.import_module(name='foo', init=init)
-        assert 'foo' in sys.modules
-
-    def test01_crossing_dict(self):
+    def test02_crossing_dict(self):
         """Test availability of all needed classes in the dict"""
 
         import cppyy
@@ -84,7 +83,7 @@
 
         assert crossing.A == crossing.A
 
-    def test02_send_pyobject(self):
+    def test03_send_pyobject(self):
         """Test sending a true pyobject to C++"""
 
         import cppyy
@@ -93,7 +92,7 @@
         a = crossing.A()
         assert a.unwrap(13) == 13
 
-    def test03_send_and_receive_pyobject(self):
+    def test04_send_and_receive_pyobject(self):
         """Test receiving a true pyobject from C++"""
 
         import cppyy
diff --git a/pypy/module/cppyy/test/test_fragile.py b/pypy/module/cppyy/test/test_fragile.py
--- a/pypy/module/cppyy/test/test_fragile.py
+++ b/pypy/module/cppyy/test/test_fragile.py
@@ -16,7 +16,7 @@
 
     def setup_class(cls):
         cls.w_test_dct  = cls.space.wrap(test_dct)
-        cls.w_capi = cls.space.wrap(capi)
+        cls.w_identity = cls.space.wrap(capi.identify())
         cls.w_fragile = cls.space.appexec([], """():
             import cppyy
             return cppyy.load_reflection_info(%r)""" % (test_dct, ))
@@ -203,7 +203,7 @@
 
         import cppyy
 
-        if self.capi.identify() == 'CINT':   # CINT only support classes on global space
+        if self.identity == 'CINT':          # CINT only support classes on global space
             members = dir(cppyy.gbl)
             assert 'TROOT' in members
             assert 'TSystem' in members


More information about the pypy-commit mailing list