[pypy-svn] rev 484 - in pypy/trunk/src/pypy: interpreter/test objspace

alex at codespeak.net alex at codespeak.net
Mon May 26 19:40:43 CEST 2003


Author: alex
Date: Mon May 26 19:40:42 2003
New Revision: 484

Modified:
   pypy/trunk/src/pypy/interpreter/test/test_extmodule.py
   pypy/trunk/src/pypy/objspace/trivial.py
Log:
fixed trivial objspace enough to make test_extmodule work



Modified: pypy/trunk/src/pypy/interpreter/test/test_extmodule.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/test/test_extmodule.py	(original)
+++ pypy/trunk/src/pypy/interpreter/test/test_extmodule.py	Mon May 26 19:40:42 2003
@@ -11,6 +11,11 @@
 class EmptyBM(extmodule.BuiltinModule):
     __pythonname__ = 'empty_bm'
 
+class BM_with_appmethod(extmodule.BuiltinModule):
+    __pythonname__ = 'bm_with_appmethod'
+    def amethod(self): return 23
+    amethod = extmodule.appmethod(amethod)
+
 class TestBuiltinModule(unittest_w.TestCase_w):
 
     def setUp(self):
@@ -30,5 +35,20 @@
         self.assertEqual(bmd['__doc__'], EmptyBM.__doc__)
         self.assertEqual(bmd['__name__'], EmptyBM.__pythonname__)
 
+    def test_appmethod(self):
+        bm = BM_with_appmethod(self.space)
+        w_bm = bm.wrap_me()
+        modobj = self.space.unwrap(w_bm)
+        bmd = modobj.__dict__
+        bmd_kys = bmd.keys()
+        bmd_kys.sort()
+        self.assertEqual(bmd_kys, ['__doc__','__name__','amethod'])
+        self.assertEqual(bmd['__doc__'], BM_with_appmethod.__doc__)
+        self.assertEqual(bmd['__name__'], BM_with_appmethod.__pythonname__)
+        self.assertEqual(bmd['amethod'].__name__, 'amethod')
+        result = bmd['amethod']()
+        self.assertEqual(result, 23)
+
+
 if __name__ == '__main__':
     unittest.main()

Modified: pypy/trunk/src/pypy/objspace/trivial.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/trivial.py	(original)
+++ pypy/trunk/src/pypy/objspace/trivial.py	Mon May 26 19:40:42 2003
@@ -182,7 +182,7 @@
                 locals = self.code.build_arguments(self.space, args, kwds,
                     w_defaults = self.defaultarguments,
                     w_closure = self.closure)
-                return self.code.evalcode(self.space, self.globals, locals)
+                return self.code.eval_code(self.space, self.globals, locals)
         return nufun(self, code, globals, defaultarguments, closure)
 
     def newstring(self, asciilist):


More information about the Pypy-commit mailing list