[pypy-commit] pypy default: Add a ztranslation test for '_hashlib'. Minor fixes to the fake objspace to make it work.
arigo
noreply at buildbot.pypy.org
Mon Mar 30 18:01:28 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r76641:82e73bc3274e
Date: 2015-03-30 18:01 +0200
http://bitbucket.org/pypy/pypy/changeset/82e73bc3274e/
Log: Add a ztranslation test for '_hashlib'. Minor fixes to the fake
objspace to make it work.
diff --git a/pypy/module/_hashlib/test/test_ztranslation.py b/pypy/module/_hashlib/test/test_ztranslation.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_hashlib/test/test_ztranslation.py
@@ -0,0 +1,4 @@
+from pypy.objspace.fake.checkmodule import checkmodule
+
+def test_checkmodule():
+ checkmodule('_hashlib')
diff --git a/pypy/module/cpyext/test/test_ztranslation.py b/pypy/module/cpyext/test/test_ztranslation.py
--- a/pypy/module/cpyext/test/test_ztranslation.py
+++ b/pypy/module/cpyext/test/test_ztranslation.py
@@ -1,4 +1,4 @@
from pypy.objspace.fake.checkmodule import checkmodule
def test_cpyext_translates():
- checkmodule('cpyext', '_rawffi')
+ checkmodule('cpyext', '_rawffi', translate_startup=False)
diff --git a/pypy/objspace/fake/checkmodule.py b/pypy/objspace/fake/checkmodule.py
--- a/pypy/objspace/fake/checkmodule.py
+++ b/pypy/objspace/fake/checkmodule.py
@@ -2,16 +2,19 @@
from pypy.config.pypyoption import get_pypy_config
-def checkmodule(*modnames):
+def checkmodule(*modnames, **kwds):
+ translate_startup = kwds.pop('translate_startup', True)
+ assert not kwds
config = get_pypy_config(translating=True)
space = FakeObjSpace(config)
seeobj_w = []
+ modules = []
for modname in modnames:
mod = __import__('pypy.module.%s' % modname, None, None, ['__doc__'])
# force computation and record what we wrap
module = mod.Module(space, W_Root())
module.setup_after_space_initialization()
- module.startup(space)
+ modules.append(module)
for name in module.loaders:
seeobj_w.append(module._load_lazily(space, name))
if hasattr(module, 'submodules'):
@@ -20,5 +23,11 @@
for name in submod.loaders:
seeobj_w.append(submod._load_lazily(space, name))
#
- space.translates(seeobj_w=seeobj_w,
+ def func():
+ for mod in modules:
+ mod.startup(space)
+ if not translate_startup:
+ func() # call it now
+ func = None
+ space.translates(func, seeobj_w=seeobj_w,
**{'translation.list_comprehension_operations': True})
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -113,7 +113,7 @@
BUILTIN_TYPES = ['int', 'str', 'float', 'long', 'tuple', 'list', 'dict',
'unicode', 'complex', 'slice', 'bool', 'basestring', 'object',
- 'bytearray', 'buffer']
+ 'bytearray', 'buffer', 'set', 'frozenset']
class FakeObjSpace(ObjSpace):
def __init__(self, config=None):
More information about the pypy-commit
mailing list