[pypy-commit] pypy kill-faking: (alex, fijal): fix interpreter tests
alex_gaynor
noreply at buildbot.pypy.org
Sun Dec 2 22:35:09 CET 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: kill-faking
Changeset: r59230:6341bd9f1673
Date: 2012-12-02 12:26 -0800
http://bitbucket.org/pypy/pypy/changeset/6341bd9f1673/
Log: (alex, fijal): fix interpreter tests
diff --git a/pypy/interpreter/test/test_main.py b/pypy/interpreter/test/test_main.py
--- a/pypy/interpreter/test/test_main.py
+++ b/pypy/interpreter/test/test_main.py
@@ -24,17 +24,18 @@
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')
diff --git a/pypy/interpreter/test/test_objspace.py b/pypy/interpreter/test/test_objspace.py
--- a/pypy/interpreter/test/test_objspace.py
+++ b/pypy/interpreter/test/test_objspace.py
@@ -320,40 +320,20 @@
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)
More information about the pypy-commit
mailing list