[pypy-svn] rev 475 - in pypy/trunk/src/pypy/interpreter: . test

alex at codespeak.net alex at codespeak.net
Mon May 26 19:02:23 CEST 2003


Author: alex
Date: Mon May 26 19:02:17 2003
New Revision: 475

Modified:
   pypy/trunk/src/pypy/interpreter/extmodule.py
   pypy/trunk/src/pypy/interpreter/test/test_extmodule.py
Log:
refactored from



Modified: pypy/trunk/src/pypy/interpreter/extmodule.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/extmodule.py	(original)
+++ pypy/trunk/src/pypy/interpreter/extmodule.py	Mon May 26 19:02:17 2003
@@ -1,5 +1,5 @@
-from pycode import PyBaseCode
-from appfile import AppHelper
+import pycode
+import appfile
 
 class appmethod(object):
     def __init__(self, func):
@@ -14,11 +14,11 @@
         return self.data
 
 
-class PyBuiltinCode(PyBaseCode):
+class PyBuiltinCode(pycode.PyBaseCode):
     """The code object implementing a built-in (interpreter-level) hook."""
 
     def __init__(self, bltinmodule, appmethod):
-        PyBaseCode.__init__(self)
+        pycode.PyBaseCode.__init__(self)
         self.bltinmodule = bltinmodule
         self.appmethod = appmethod
         co = appmethod.func.func_code
@@ -63,8 +63,8 @@
             elif isinstance(value, appdata):
                 w_data = space.wrap(value.data)
                 space.setattr(w_module, space.wrap(key), w_data)
-        appfile = self.__appfile__
-        if appfile:
+        sappfile = self.__appfile__
+        if sappfile:
             w_dict = space.getattr(w_module, space.wrap("__dict__"))
-            AppHelper(space, appfile, w_dict)
+            appfile.AppHelper(space, sappfile, w_dict)
         return w_module

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:02:17 2003
@@ -1,32 +1,17 @@
 import unittest, sys
-sys.path.append('..')
+import testsupport
+from pypy.interpreter import unittest_w
 
-import extmodule
+from pypy.interpreter import extmodule
+from pypy.objspace import trivial
 
 class EmptyBM(extmodule.BuiltinModule):
     __pythonname__ = 'empty_bm'
 
-class wrapper(object):
-    def __init__(self, wrapped):
-        self.wrapped = wrapped
-def is_wrapped(obj):
-    return isinstance(obj, wrapper)
-import new
-class dummyspace(object):
-    w_None = wrapper(None)
-    def wrap(self, obj):
-        return wrapper(obj)
-    def unwrap(self, obj):
-        return obj.wrapped
-    def newmodule(self, name):
-        return self.wrap(new.module(self.unwrap(name)))
-    def newfunction(self, code, w_something, somethingelse):
-
-
-class TestBuiltinModule(unittest.TestCase):
+class TestBuiltinModule(unittest_w.TestCase_w):
 
     def setUp(self):
-        self.space = dummyspace()
+        self.space = trivial.TrivialObjSpace()
 
     def tearDown(self):
         pass


More information about the Pypy-commit mailing list