[pypy-svn] r10140 - pypy/dist/pypy/translator/test
tismer at codespeak.net
tismer at codespeak.net
Sun Mar 27 22:30:50 CEST 2005
Author: tismer
Date: Sun Mar 27 22:30:50 2005
New Revision: 10140
Modified:
pypy/dist/pypy/translator/test/test_geninterp.py
Log:
added a test for import. This is for applevelonly, so we chime
it in at testing time, not modifying snippets.py.
Modified: pypy/dist/pypy/translator/test/test_geninterp.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_geninterp.py (original)
+++ pypy/dist/pypy/translator/test/test_geninterp.py Sun Mar 27 22:30:50 2005
@@ -38,19 +38,27 @@
class TestGenRpyTestCase:
objspacename = 'std'
+ snippet_ad = """if 1:
+ def import_func():
+ import copy_reg
+ return copy_reg._reconstructor.func_code.co_name"""
+
def __init__(self):
# simply compile snippets just once
src = str(Source(snippet))
# truncate non-compilable stuff for now:
p = src.index('Non compilable Functions')
- src = src[:p]
+ src = src[:p] + '\n'
+ # put our ad into snippet
+ exec self.snippet_ad in snippet.__dict__
+ src += self.snippet_ad
# just in case of trouble, we produce a tempfile
ini = translate_as_module(src, tmpname = str(udir.join("_geninterp_test.py")))
self.w_glob = ini(self.space)
def build_interpfunc(self, func, *morefuncs):
# we ignore morefuncs, since they live in snippets
- space =self.space
+ space = self.space
func = space.getitem(self.w_glob, space.wrap(func.__name__))
def wrapunwrap(*args):
w_args = space.wrap(args)
@@ -65,6 +73,12 @@
return space.unwrap(w_res)
return wrapunwrap
+ # small addition to see whether imports look fine
+ def test_import(self):
+ import copy_reg
+ impfunc = self.build_interpfunc(snippet.import_func)
+ assert impfunc() == '_reconstructor'
+
def test_simple_func(self):
cfunc = self.build_interpfunc(snippet.simple_func)
assert cfunc(1) == 2
More information about the Pypy-commit
mailing list