1. Stephen Tu
  2. mino-pypy

Commits

Alex Gaynor  committed 6341bd9

(alex, fijal): fix interpreter tests

  • Participants
  • Parent commits 395e792
  • Branches kill-faking

Comments (0)

Files changed (2)

File pypy/interpreter/test/test_main.py

View file
 
 testresultoutput = '11\n'
 
-def checkoutput(space, expected_output,f,*args):
+
+def checkoutput(space, expected_output, f, *args):
     w_oldout = space.sys.get('stdout')
     capturefn = udir.join('capturefile')
-    capturefile = capturefn.open('w')
+    w_capturefile = space.call_method(space.builtin, "open", space.wrap(str(capturefn)), space.wrap("w"))
     w_sys = space.sys.getmodule('sys')
-    space.setattr(w_sys, space.wrap("stdout"), space.wrap(capturefile))
+    space.setattr(w_sys, space.wrap("stdout"), w_capturefile)
     try:
         f(*(args + (space,)))
     finally:
         space.setattr(w_sys, space.wrap("stdout"), w_oldout)
-    capturefile.close()
+    space.call_method(w_capturefile, "close")
     assert capturefn.read(mode='rU') == expected_output
 
 testfn = udir.join('tmp_hello_world.py')

File pypy/interpreter/test/test_objspace.py

View file
 
 class TestModuleMinimal: 
     def test_sys_exists(self):
-        assert self.space.sys 
+        assert self.space.sys
 
     def test_import_exists(self):
         space = self.space
-        assert space.builtin 
+        assert space.builtin
         w_name = space.wrap('__import__')
         w_builtin = space.sys.getmodule('__builtin__')
-        w_import = self.space.getattr(w_builtin, w_name) 
+        w_import = self.space.getattr(w_builtin, w_name)
         assert space.is_true(w_import)
 
     def test_sys_import(self):
         from pypy.interpreter.main import run_string
         run_string('import sys', space=self.space)
 
-    def test_get_builtinmodule_to_install(self):
-        space = self.space
-        try:
-            # force rebuilding with this fake builtin
-            space.ALL_BUILTIN_MODULES.append('this_doesnt_exist')
-            del space._builtinmodule_list
-            mods = space.get_builtinmodule_to_install()
-            
-            assert '__pypy__' in mods                # real builtin
-            assert '_functools' not in mods               # in lib_pypy
-            assert 'faked+_functools' not in mods         # in lib_pypy
-            assert 'this_doesnt_exist' not in mods   # not in lib_pypy
-            assert 'faked+this_doesnt_exist' in mods # not in lib_pypy, but in
-                                                     # ALL_BUILTIN_MODULES
-        finally:
-            # rebuild the original list
-            space.ALL_BUILTIN_MODULES.pop()
-            del space._builtinmodule_list
-            mods = space.get_builtinmodule_to_install()
-
     def test_dont_reload_builtin_mods_on_startup(self):
         from pypy.tool.option import make_config, make_objspace
         config = make_config(None)