Author: Amaury Forgeot d'Arc <[email protected]>
Branch: less-gettestobjspace
Changeset: r58628:a69f63c9603d
Date: 2012-10-30 00:49 +0100
http://bitbucket.org/pypy/pypy/changeset/a69f63c9603d/
Log: Oops, move TinyObjSpace as well, to fix -A tests.
diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -72,85 +72,6 @@
spaceconfig = getattr(request.cls, 'spaceconfig', {})
return gettestobjspace(**spaceconfig)
-class TinyObjSpace(object):
- def __init__(self, **kwds):
- import sys
- info = getattr(sys, 'pypy_translation_info', None)
- for key, value in kwds.iteritems():
- if key == 'usemodules':
- if info is not None:
- for modname in value:
- ok = info.get('objspace.usemodules.%s' % modname,
- False)
- if not ok:
- py.test.skip("cannot runappdirect test: "
- "module %r required" % (modname,))
- else:
- if '__pypy__' in value:
- py.test.skip("no module __pypy__ on top of CPython")
- continue
- if info is None:
- py.test.skip("cannot runappdirect this test on top of CPython")
- has = info.get(key, None)
- if has != value:
- #print sys.pypy_translation_info
- py.test.skip("cannot runappdirect test: space needs %s = %s, "\
- "while pypy-c was built with %s" % (key, value, has))
-
- for name in ('int', 'long', 'str', 'unicode', 'None'):
- setattr(self, 'w_' + name, eval(name))
-
-
- def appexec(self, args, body):
- body = body.lstrip()
- assert body.startswith('(')
- src = py.code.Source("def anonymous" + body)
- d = {}
- exec src.compile() in d
- return d['anonymous'](*args)
-
- def wrap(self, obj):
- return obj
-
- def unpackiterable(self, itr):
- return list(itr)
-
- def is_true(self, obj):
- return bool(obj)
-
- def str_w(self, w_str):
- return w_str
-
- def newdict(self, module=None):
- return {}
-
- def newtuple(self, iterable):
- return tuple(iterable)
-
- def newlist(self, iterable):
- return list(iterable)
-
- def call_function(self, func, *args, **kwds):
- return func(*args, **kwds)
-
- def call_method(self, obj, name, *args, **kwds):
- return getattr(obj, name)(*args, **kwds)
-
- def getattr(self, obj, name):
- return getattr(obj, name)
-
- def setattr(self, obj, name, value):
- setattr(obj, name, value)
-
- def getbuiltinmodule(self, name):
- return __import__(name)
-
- def delslice(self, obj, *args):
- obj.__delslice__(*args)
-
- def is_w(self, obj1, obj2):
- return obj1 is obj2
-
def translation_test_so_skip_if_appdirect():
if option.runappdirect:
py.test.skip("translation test, skipped for appdirect")
diff --git a/pypy/tool/pytest/objspace.py b/pypy/tool/pytest/objspace.py
--- a/pypy/tool/pytest/objspace.py
+++ b/pypy/tool/pytest/objspace.py
@@ -44,3 +44,83 @@
space.eq_w = appsupport.eq_w.__get__(space)
return space
+
+class TinyObjSpace(object):
+ """An object space that delegates everything to the hosting Python."""
+ def __init__(self, **kwds):
+ import sys
+ info = getattr(sys, 'pypy_translation_info', None)
+ for key, value in kwds.iteritems():
+ if key == 'usemodules':
+ if info is not None:
+ for modname in value:
+ ok = info.get('objspace.usemodules.%s' % modname,
+ False)
+ if not ok:
+ py.test.skip("cannot runappdirect test: "
+ "module %r required" % (modname,))
+ else:
+ if '__pypy__' in value:
+ py.test.skip("no module __pypy__ on top of CPython")
+ continue
+ if info is None:
+ py.test.skip("cannot runappdirect this test on top of CPython")
+ has = info.get(key, None)
+ if has != value:
+ #print sys.pypy_translation_info
+ py.test.skip("cannot runappdirect test: space needs %s = %s, "\
+ "while pypy-c was built with %s" % (key, value, has))
+
+ for name in ('int', 'long', 'str', 'unicode', 'None'):
+ setattr(self, 'w_' + name, eval(name))
+
+ def appexec(self, args, body):
+ body = body.lstrip()
+ assert body.startswith('(')
+ src = py.code.Source("def anonymous" + body)
+ d = {}
+ exec src.compile() in d
+ return d['anonymous'](*args)
+
+ def wrap(self, obj):
+ return obj
+
+ def unpackiterable(self, itr):
+ return list(itr)
+
+ def is_true(self, obj):
+ return bool(obj)
+
+ def str_w(self, w_str):
+ return w_str
+
+ def newdict(self, module=None):
+ return {}
+
+ def newtuple(self, iterable):
+ return tuple(iterable)
+
+ def newlist(self, iterable):
+ return list(iterable)
+
+ def call_function(self, func, *args, **kwds):
+ return func(*args, **kwds)
+
+ def call_method(self, obj, name, *args, **kwds):
+ return getattr(obj, name)(*args, **kwds)
+
+ def getattr(self, obj, name):
+ return getattr(obj, name)
+
+ def setattr(self, obj, name, value):
+ setattr(obj, name, value)
+
+ def getbuiltinmodule(self, name):
+ return __import__(name)
+
+ def delslice(self, obj, *args):
+ obj.__delslice__(*args)
+
+ def is_w(self, obj1, obj2):
+ return obj1 is obj2
+
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit