[pypy-commit] pypy less-gettestobjspace: progress: removed many usages of gettestobjspace from objspace/std tests.

amauryfa noreply at buildbot.pypy.org
Mon Oct 29 22:40:24 CET 2012


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: less-gettestobjspace
Changeset: r58620:9189ff822a90
Date: 2012-10-29 01:48 +0100
http://bitbucket.org/pypy/pypy/changeset/9189ff822a90/

Log:	progress: removed many usages of gettestobjspace from objspace/std
	tests.

diff --git a/pypy/objspace/std/test/test_builtinshortcut.py b/pypy/objspace/std/test/test_builtinshortcut.py
--- a/pypy/objspace/std/test/test_builtinshortcut.py
+++ b/pypy/objspace/std/test/test_builtinshortcut.py
@@ -5,15 +5,13 @@
 WITH_BUILTINSHORTCUT = {'objspace.std.builtinshortcut': True}
 
 class AppTestUserObject(test_userobject.AppTestUserObject):
-    OPTIONS = WITH_BUILTINSHORTCUT
+    spaceconfig = WITH_BUILTINSHORTCUT
 
 class AppTestWithMultiMethodVersion2(test_userobject.AppTestWithMultiMethodVersion2):
-    OPTIONS = WITH_BUILTINSHORTCUT
+    spaceconfig = WITH_BUILTINSHORTCUT
 
 class AppTestBug:
-    def setup_class(cls):
-        from pypy import conftest
-        cls.space = conftest.gettestobjspace(**WITH_BUILTINSHORTCUT)
+    spaceconfig = WITH_BUILTINSHORTCUT
 
     def test_frozen_subtype(self):
         class S(set): pass
@@ -81,10 +79,9 @@
    
 
 class AppTestSet(test_setobject.AppTestAppSetTest):
+    spaceconfig = WITH_BUILTINSHORTCUT
     # this tests tons of funny comparison combinations that can easily go wrong
     def setup_class(cls):
-        from pypy import conftest
-        cls.space = conftest.gettestobjspace(**WITH_BUILTINSHORTCUT)
         w_fakeint = cls.space.appexec([], """():
             class FakeInt(object):
                 def __init__(self, value):
@@ -101,6 +98,4 @@
         cls.w_FakeInt = w_fakeint
 
 class AppTestString(test_stringobject.AppTestStringObject):
-    def setup_class(cls):
-        from pypy import conftest
-        cls.space = conftest.gettestobjspace(**WITH_BUILTINSHORTCUT)
+    spaceconfig = WITH_BUILTINSHORTCUT
diff --git a/pypy/objspace/std/test/test_callmethod.py b/pypy/objspace/std/test/test_callmethod.py
--- a/pypy/objspace/std/test/test_callmethod.py
+++ b/pypy/objspace/std/test/test_callmethod.py
@@ -1,15 +1,8 @@
-import py
-from pypy.conftest import gettestobjspace
-
-
 class AppTestCallMethod:
     # The exec hacking is needed to have the code snippets compiled
     # by our own compiler, not CPython's
 
-    OPTIONS = {"objspace.opcodes.CALL_METHOD": True}
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**cls.OPTIONS)
+    spaceconfig = {"objspace.opcodes.CALL_METHOD": True}
 
     def test_call_method(self):
         exec """if 1:
@@ -118,14 +111,12 @@
 
 
 class AppTestCallMethodWithGetattributeShortcut(AppTestCallMethod):
-    OPTIONS = AppTestCallMethod.OPTIONS.copy()
-    OPTIONS["objspace.std.getattributeshortcut"] = True
+    spaceconfig = AppTestCallMethod.spaceconfig.copy()
+    spaceconfig["objspace.std.getattributeshortcut"] = True
 
 
 class TestCallMethod:
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.opcodes.CALL_METHOD": True})
+    spaceconfig = {"objspace.opcodes.CALL_METHOD": True}
 
     def test_space_call_method(self):
         space = self.space
diff --git a/pypy/objspace/std/test/test_celldict.py b/pypy/objspace/std/test/test_celldict.py
--- a/pypy/objspace/std/test/test_celldict.py
+++ b/pypy/objspace/std/test/test_celldict.py
@@ -1,5 +1,4 @@
 import py
-from pypy.conftest import gettestobjspace, option
 from pypy.objspace.std.dictmultiobject import W_DictMultiObject
 from pypy.objspace.std.celldict import ModuleCell, ModuleDictStrategy
 from pypy.objspace.std.test.test_dictmultiobject import FakeSpace, \
@@ -54,9 +53,10 @@
         assert v2 is v3
 
 class AppTestModuleDict(object):
+    spaceconfig = {"objspace.std.withcelldict": True}
+
     def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withcelldict": True})
-        cls.w_runappdirect = cls.space.wrap(option.runappdirect)
+        cls.w_runappdirect = cls.space.wrap(cls.option.runappdirect)
 
     def w_impl_used(self, obj):
         if self.runappdirect:
@@ -122,10 +122,10 @@
 
 
 class AppTestCellDict(object):
-    OPTIONS = {"objspace.std.withcelldict": True}
+    spaceconfig = {"objspace.std.withcelldict": True}
 
     def setup_class(cls):
-        if option.runappdirect:
+        if cls.option.runappdirect:
             py.test.skip("__repr__ doesn't work on appdirect")
         strategy = ModuleDictStrategy(cls.space)
         storage = strategy.get_empty_storage()
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -5,14 +5,8 @@
      W_DictMultiObject, setitem__DictMulti_ANY_ANY, getitem__DictMulti_ANY, \
      StringDictStrategy, ObjectDictStrategy
 
-from pypy.conftest import gettestobjspace
-from pypy.conftest import option
-
 class TestW_DictObject:
 
-    def setup_class(cls):
-        cls.space = gettestobjspace()
-
     def test_empty(self):
         space = self.space
         d = self.space.newdict()
@@ -777,7 +771,7 @@
 
 class AppTestStrategies(object):
     def setup_class(cls):
-        if option.runappdirect:
+        if cls.option.runappdirect:
             py.test.skip("__repr__ doesn't work on appdirect")
 
     def w_get_strategy(self, obj):
diff --git a/pypy/objspace/std/test/test_dictproxy.py b/pypy/objspace/std/test/test_dictproxy.py
--- a/pypy/objspace/std/test/test_dictproxy.py
+++ b/pypy/objspace/std/test/test_dictproxy.py
@@ -1,5 +1,3 @@
-from pypy.conftest import gettestobjspace
-
 class AppTestUserObject:
     def test_dictproxy(self):
         class NotEmpty(object):
@@ -62,7 +60,5 @@
         raises(TypeError, int.__dict__.clear)
 
 class AppTestUserObjectMethodCache(AppTestUserObject):
-    def setup_class(cls):
-        cls.space = gettestobjspace(
-            **{"objspace.std.withmethodcachecounter": True})
+    spaceconfig = {"objspace.std.withmethodcachecounter": True}
 
diff --git a/pypy/objspace/std/test/test_identitydict.py b/pypy/objspace/std/test/test_identitydict.py
--- a/pypy/objspace/std/test/test_identitydict.py
+++ b/pypy/objspace/std/test/test_identitydict.py
@@ -1,15 +1,12 @@
 import py
 from pypy.interpreter.gateway import interp2app
-from pypy.conftest import gettestobjspace
-from pypy.conftest import option
 
 class AppTestComparesByIdentity:
+    spaceconfig = {"objspace.std.withidentitydict": True}
 
     def setup_class(cls):
         from pypy.objspace.std import identitydict
-        cls.space = gettestobjspace(
-                        **{"objspace.std.withidentitydict": True})
-        if option.runappdirect:
+        if cls.option.runappdirect:
             py.test.skip("interp2app doesn't work on appdirect")
 
         def compares_by_identity(space, w_cls):
@@ -59,9 +56,10 @@
 
 
 class AppTestIdentityDict(object):
+    spaceconfig = {"objspace.std.withidentitydict": True}
+
     def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withidentitydict": True})
-        if option.runappdirect:
+        if cls.option.runappdirect:
             py.test.skip("interp2app doesn't work on appdirect")
 
     def w_uses_identity_strategy(self, obj):
diff --git a/pypy/objspace/std/test/test_index.py b/pypy/objspace/std/test/test_index.py
--- a/pypy/objspace/std/test/test_index.py
+++ b/pypy/objspace/std/test/test_index.py
@@ -1,9 +1,7 @@
 from py.test import raises
-from pypy.conftest import gettestobjspace
 
 class AppTest_IndexProtocol:
     def setup_class(self):
-        self.space = gettestobjspace()
         w_oldstyle = self.space.appexec([], """():
             class oldstyle:
                 def __index__(self):
diff --git a/pypy/objspace/std/test/test_intobject.py b/pypy/objspace/std/test/test_intobject.py
--- a/pypy/objspace/std/test/test_intobject.py
+++ b/pypy/objspace/std/test/test_intobject.py
@@ -500,12 +500,7 @@
 
 
 class AppTestIntOptimizedAdd(AppTestInt):
-    def setup_class(cls):
-        from pypy.conftest import gettestobjspace
-        cls.space = gettestobjspace(**{"objspace.std.optimized_int_add": True})
+    spaceconfig = {"objspace.std.optimized_int_add": True}
 
 class AppTestIntOptimizedComp(AppTestInt):
-    def setup_class(cls):
-        from pypy.conftest import gettestobjspace
-        cls.space = gettestobjspace(**{"objspace.std.optimized_comparison_op": True})
-        
+    spaceconfig = {"objspace.std.optimized_comparison_op": True}
diff --git a/pypy/objspace/std/test/test_kwargsdict.py b/pypy/objspace/std/test/test_kwargsdict.py
--- a/pypy/objspace/std/test/test_kwargsdict.py
+++ b/pypy/objspace/std/test/test_kwargsdict.py
@@ -1,5 +1,4 @@
 import py
-from pypy.conftest import gettestobjspace, option
 from pypy.objspace.std.test.test_dictmultiobject import FakeSpace, W_DictMultiObject
 from pypy.objspace.std.kwargsdict import *
 
@@ -125,7 +124,7 @@
 
 class AppTestKwargsDictStrategy(object):
     def setup_class(cls):
-        if option.runappdirect:
+        if cls.option.runappdirect:
             py.test.skip("__repr__ doesn't work on appdirect")
 
     def w_get_strategy(self, obj):
diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -5,8 +5,6 @@
 from pypy.interpreter.error import OperationError
 from pypy.rlib.rarithmetic import is_valid_int
 
-from pypy.conftest import gettestobjspace, option
-
 
 class TestW_ListObject(object):
     def test_is_true(self):
@@ -406,10 +404,10 @@
 class AppTestW_ListObject(object):
     def setup_class(cls):
         import sys
-        on_cpython = (option.runappdirect and
-                            not hasattr(sys, 'pypy_translation_info'))
+        on_cpython = (cls.option.runappdirect and
+                      not hasattr(sys, 'pypy_translation_info'))
         cls.w_on_cpython = cls.space.wrap(on_cpython)
-        cls.w_runappdirect = cls.space.wrap(option.runappdirect)
+        cls.w_runappdirect = cls.space.wrap(cls.option.runappdirect)
 
     def test_getstrategyfromlist_w(self):
         l0 = ["a", "2", "a", True]
@@ -1256,10 +1254,7 @@
         assert ([5] >= [N]) is False
 
 class AppTestForRangeLists(AppTestW_ListObject):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withrangelist" :
-                                       True})
+    spaceconfig = {"objspace.std.withrangelist": True}
 
     def test_range_simple_backwards(self):
         x = range(5,1)
@@ -1376,10 +1371,7 @@
 
 
 class AppTestWithoutStrategies(object):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withliststrategies" :
-                                       False})
+    spaceconfig = {"objspace.std.withliststrategies": False}
 
     def test_no_shared_empty_list(self):
         l = []
@@ -1391,10 +1383,7 @@
         assert notshared == []
 
 class AppTestListFastSubscr:
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.optimized_list_getitem" :
-                                       True})
+    spaceconfig = {"objspace.std.optimized_list_getitem": True}
 
     def test_getitem(self):
         import operator
diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py
--- a/pypy/objspace/std/test/test_liststrategies.py
+++ b/pypy/objspace/std/test/test_liststrategies.py
@@ -3,8 +3,6 @@
 from pypy.objspace.std import listobject
 from pypy.objspace.std.test.test_listobject import TestW_ListObject
 
-from pypy.conftest import gettestobjspace
-
 class TestW_ListStrategies(TestW_ListObject):
 
     def test_check_strategy(self):
@@ -520,9 +518,7 @@
 
 
 class TestW_ListStrategiesDisabled:
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withliststrategies" :
-                                       False})
+    spaceconfig = {"objspace.std.withliststrategies": False}
 
     def test_check_strategy(self):
         assert isinstance(W_ListObject(self.space, []).strategy, ObjectListStrategy)
diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py
--- a/pypy/objspace/std/test/test_longobject.py
+++ b/pypy/objspace/std/test/test_longobject.py
@@ -5,12 +5,9 @@
 from pypy.interpreter.error import OperationError
 from pypy.rlib.rarithmetic import r_uint
 from pypy.rlib.rbigint import rbigint
-from pypy.conftest import gettestobjspace
 
 class TestW_LongObject:
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.nofaking": True})
+    spaceconfig = {"objspace.nofaking": True}
 
     def test_bigint_w(self):
         space = self.space
diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -1,4 +1,3 @@
-from pypy.conftest import gettestobjspace, option
 from pypy.objspace.std.test.test_dictmultiobject import FakeSpace, W_DictMultiObject
 from pypy.objspace.std.mapdict import *
 
@@ -438,8 +437,7 @@
 # XXX write more
 
 class AppTestWithMapDict(object):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withmapdict": True})
+    spaceconfig = {"objspace.std.withmapdict": True}
 
     def test_simple(self):
         class A(object):
@@ -647,12 +645,12 @@
         raises(AttributeError, "a.x")
 
 class AppTestWithMapDictAndCounters(object):
+    spaceconfig = {"objspace.std.withmapdict": True,
+                   "objspace.std.withmethodcachecounter": True,
+                   "objspace.opcodes.CALL_METHOD": True}
+
     def setup_class(cls):
         from pypy.interpreter import gateway
-        cls.space = gettestobjspace(
-            **{"objspace.std.withmapdict": True,
-               "objspace.std.withmethodcachecounter": True,
-               "objspace.opcodes.CALL_METHOD": True})
         #
         def check(space, w_func, name):
             w_code = space.getattr(w_func, space.wrap('func_code'))
@@ -992,11 +990,9 @@
         assert got == 'd'
 
 class AppTestGlobalCaching(AppTestWithMapDict):
-    def setup_class(cls):
-        cls.space = gettestobjspace(
-            **{"objspace.std.withmethodcachecounter": True,
-               "objspace.std.withmapdict": True,
-               "objspace.opcodes.CALL_METHOD": True})
+    spaceconfig = {"objspace.std.withmethodcachecounter": True,
+                   "objspace.std.withmapdict": True,
+                   "objspace.opcodes.CALL_METHOD": True}
 
     def test_mix_classes(self):
         import __pypy__
@@ -1053,10 +1049,8 @@
             assert 0, "failed: got %r" % ([got[1] for got in seen],)
 
 class TestDictSubclassShortcutBug(object):
-    def setup_class(cls):
-        cls.space = gettestobjspace(
-            **{"objspace.std.withmapdict": True,
-               "objspace.std.withmethodcachecounter": True})
+    spaceconfig = {"objspace.std.withmapdict": True,
+                   "objspace.std.withmethodcachecounter": True}
 
     def test_bug(self):
         w_dict = self.space.appexec([], """():
diff --git a/pypy/objspace/std/test/test_methodcache.py b/pypy/objspace/std/test/test_methodcache.py
--- a/pypy/objspace/std/test/test_methodcache.py
+++ b/pypy/objspace/std/test/test_methodcache.py
@@ -1,11 +1,8 @@
-from pypy.conftest import gettestobjspace
 from pypy.objspace.std.test import test_typeobject
 
 
 class AppTestMethodCaching(test_typeobject.AppTestTypeObject):
-    def setup_class(cls):
-        cls.space = gettestobjspace(
-            **{"objspace.std.withmethodcachecounter": True})
+    spaceconfig = {"objspace.std.withmethodcachecounter": True}
 
     def test_mix_classes(self):
         import __pypy__
diff --git a/pypy/objspace/std/test/test_newformat.py b/pypy/objspace/std/test/test_newformat.py
--- a/pypy/objspace/std/test/test_newformat.py
+++ b/pypy/objspace/std/test/test_newformat.py
@@ -1,6 +1,5 @@
 """Test unicode/str's format method"""
 from __future__ import with_statement
-from pypy.conftest import gettestobjspace
 
 
 class BaseStringFormatTests:
@@ -315,8 +314,7 @@
 
 
 class AppTestFloatFormatting:
-    def setup_class(cls):
-        cls.space = gettestobjspace(usemodules=('_locale',))
+    spaceconfig = dict(usemodules=('_locale',))
 
     def test_alternate(self):
         raises(ValueError, format, 1.0, "#")
diff --git a/pypy/objspace/std/test/test_prebuiltint.py b/pypy/objspace/std/test/test_prebuiltint.py
--- a/pypy/objspace/std/test/test_prebuiltint.py
+++ b/pypy/objspace/std/test/test_prebuiltint.py
@@ -1,10 +1,10 @@
 from pypy.objspace.std.test import test_intobject
-from pypy.conftest import gettestobjspace
 
 class AppTestInt(test_intobject.AppTestInt):
+    spaceconfig = {"objspace.std.withprebuiltint": True}
+
     def setup_class(cls):
-        cls.space = space = gettestobjspace(
-            **{"objspace.std.withprebuiltint": True})
+        space = cls.space
         cls.w_start = space.wrap(space.config.objspace.std.prebuiltintfrom)
         cls.w_stop = space.wrap(space.config.objspace.std.prebuiltintto)
 
diff --git a/pypy/objspace/std/test/test_proxy.py b/pypy/objspace/std/test/test_proxy.py
--- a/pypy/objspace/std/test/test_proxy.py
+++ b/pypy/objspace/std/test/test_proxy.py
@@ -2,11 +2,8 @@
 """ test transparent proxy features
 """
 
-from pypy.conftest import gettestobjspace
-
 class AppProxyBasic(object):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withtproxy": True})
+    spaceconfig = {"objspace.std.withtproxy": True}
         
     def setup_method(self, meth):
         self.w_Controller = self.space.appexec([], """():
diff --git a/pypy/objspace/std/test/test_proxy_function.py b/pypy/objspace/std/test/test_proxy_function.py
--- a/pypy/objspace/std/test/test_proxy_function.py
+++ b/pypy/objspace/std/test/test_proxy_function.py
@@ -2,12 +2,10 @@
 """ test proxy on functions and other crazy goodies
 """
 
-from pypy.conftest import gettestobjspace
 from pypy.objspace.std.test.test_proxy import AppProxyBasic
 
 class AppTestProxyFunction(object):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withtproxy": True})
+    spaceconfig = {"objspace.std.withtproxy": True}
 
     def setup_method(self, meth):
         self.w_get_proxy = self.space.appexec([], """():
diff --git a/pypy/objspace/std/test/test_proxy_internals.py b/pypy/objspace/std/test/test_proxy_internals.py
--- a/pypy/objspace/std/test/test_proxy_internals.py
+++ b/pypy/objspace/std/test/test_proxy_internals.py
@@ -2,11 +2,9 @@
 """ test proxy internals like code, traceback, frame
 """
 import py
-from pypy.conftest import gettestobjspace, option
 
 class AppProxy(object):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withtproxy": True})
+    spaceconfig = {"objspace.std.withtproxy": True}
 
     def setup_method(self, meth):
         self.w_get_proxy = self.space.appexec([], """():
@@ -24,7 +22,7 @@
 
 class AppTestProxyInterpOnly(AppProxy):
     def setup_class(cls):
-        if option.runappdirect:
+        if cls.option.runappdirect:
             py.test.skip("interp only test")
         from pypy.interpreter.typedef import TypeDef, interp2app
         from pypy.interpreter.baseobjspace import Wrappable
diff --git a/pypy/objspace/std/test/test_rangeobject.py b/pypy/objspace/std/test/test_rangeobject.py
--- a/pypy/objspace/std/test/test_rangeobject.py
+++ b/pypy/objspace/std/test/test_rangeobject.py
@@ -1,14 +1,12 @@
 import py
 
-from pypy.conftest import gettestobjspace, option
-
 class AppTestRangeListObject(object):
+    spaceconfig = {"objspace.std.withrangelist": True}
 
     def setup_class(cls):
-        if option.runappdirect:
+        if cls.option.runappdirect:
             py.test.skip("__pypy__.internal_repr() cannot be used to see "
                          "if a range list was forced on top of pypy-c")
-        cls.space = gettestobjspace(**{"objspace.std.withrangelist": True})
         cls.w_not_forced = cls.space.appexec([], """():
             import __pypy__
             def f(r):
diff --git a/pypy/objspace/std/test/test_ropeobject.py b/pypy/objspace/std/test/test_ropeobject.py
--- a/pypy/objspace/std/test/test_ropeobject.py
+++ b/pypy/objspace/std/test/test_ropeobject.py
@@ -1,12 +1,9 @@
 import py
 
 from pypy.objspace.std.test import test_stringobject, test_unicodeobject
-from pypy.conftest import gettestobjspace
 
 class AppTestRopeObject(test_stringobject.AppTestStringObject):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withrope": True})
+    spaceconfig = {"objspace.std.withrope": True}
 
     def test_mul_overflow(self):
         import sys
@@ -52,9 +49,7 @@
         pass
  
 class AppTestRopeUnicode(object):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withrope": True})
+    spaceconfig = {"objspace.std.withrope": True}
 
     def test_startswith(self):
         assert "abc".startswith("a", 0, 2147483647)
@@ -65,29 +60,21 @@
 
 
 class TestUnicodeRopeObject(test_unicodeobject.TestUnicodeObject):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withrope": True})
-
+    spaceconfig = {"objspace.std.withrope": True}
 
 class AppTestUnicodeRopeStdOnly(test_unicodeobject.AppTestUnicodeStringStdOnly):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withrope": True})
+    spaceconfig = {"objspace.std.withrope": True}
 
 class AppTestUnicodeRope(test_unicodeobject.AppTestUnicodeString):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(usemodules=('unicodedata',),
-                                    **{"objspace.std.withrope": True})
+    spaceconfig = dict(usemodules=('unicodedata',),
+                       **{"objspace.std.withrope": True})
 
     def test_rfind_corner_case(self):
         skip("XXX Fix")
 
 class AppTestPrebuilt(AppTestRopeObject):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withrope": True,
-                                       "objspace.std.withprebuiltchar": False})
+    spaceconfig = {"objspace.std.withrope": True,
+                   "objspace.std.withprebuiltchar": False}
 
     def test_hash(self):
         # does not make sense, since our hash is different than CPython's
@@ -95,19 +82,17 @@
  
 
 class AppTestShare(AppTestRopeObject):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withrope": True,
-                                       "objspace.std.sharesmallstr": False})
+    spaceconfig = {"objspace.std.withrope": True,
+                   "objspace.std.sharesmallstr": False}
 
     def test_hash(self):
         # does not make sense, since our hash is different than CPython's
         pass
  
 class AppTestPrebuiltShare(AppTestRopeObject):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withrope": True,
-                                       "objspace.std.withprebuiltchar": False,
-                                       "objspace.std.sharesmallstr": False})
+    spaceconfig = {"objspace.std.withrope": True,
+                   "objspace.std.withprebuiltchar": False,
+                   "objspace.std.sharesmallstr": False}
 
     def test_hash(self):
         # does not make sense, since our hash is different than CPython's
diff --git a/pypy/objspace/std/test/test_ropeunicodeobject.py b/pypy/objspace/std/test/test_ropeunicodeobject.py
--- a/pypy/objspace/std/test/test_ropeunicodeobject.py
+++ b/pypy/objspace/std/test/test_ropeunicodeobject.py
@@ -1,18 +1,13 @@
 import py
 
 from pypy.objspace.std.test import test_stringobject, test_unicodeobject
-from pypy.conftest import gettestobjspace
 
 class TestRopeUnicodeObject(test_unicodeobject.TestUnicodeObject):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withropeunicode": True})
+    spaceconfig = {"objspace.std.withropeunicode": True}
 
 
 class AppTestRopeObject(test_stringobject.AppTestStringObject):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withropeunicode": True})
+    spaceconfig = {"objspace.std.withropeunicode": True}
 
     def test_hash(self):
         # doesn't make sense, since ropes hash differently than cpython's
@@ -23,23 +18,17 @@
         skip("XXX fix")
 
 class AppTestRopeUnicode(object):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withropeunicode": True})
+    spaceconfig = {"objspace.std.withropeunicode": True}
 
     def test_replace_buffer(self):
         skip("XXX fix")
 
 class AppTestUnicodeRopeStdOnly(test_unicodeobject.AppTestUnicodeStringStdOnly):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withropeunicode": True})
+    spaceconfig = {"objspace.std.withropeunicode": True}
 
 class AppTestUnicodeRope(test_unicodeobject.AppTestUnicodeString):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(usemodules=('unicodedata',),
-                                    **{"objspace.std.withropeunicode": True})
+    spaceconfig = dict(usemodules=('unicodedata',),
+                       **{"objspace.std.withropeunicode": True})
 
     def test_replace_buffer(self):
         skip("XXX fix")
diff --git a/pypy/objspace/std/test/test_setobject.py b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -15,7 +15,6 @@
 from pypy.objspace.std.setobject import and__Set_Set
 from pypy.objspace.std.setobject import set_intersection__Set
 from pypy.objspace.std.setobject import eq__Set_Set
-from pypy.conftest import gettestobjspace
 from pypy.objspace.std.listobject import W_ListObject
 
 letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
@@ -140,7 +139,6 @@
 class AppTestAppSetTest:
 
     def setup_class(self):
-        self.space = gettestobjspace()
         w_fakeint = self.space.appexec([], """():
             class FakeInt(object):
                 def __init__(self, value):
diff --git a/pypy/objspace/std/test/test_smallintobject.py b/pypy/objspace/std/test/test_smallintobject.py
--- a/pypy/objspace/std/test/test_smallintobject.py
+++ b/pypy/objspace/std/test/test_smallintobject.py
@@ -9,12 +9,9 @@
 from pypy.rlib.rarithmetic import r_uint
 
 from pypy.objspace.std.test.test_intobject import AppTestInt
-from pypy.conftest import gettestobjspace
 
 class TestW_IntObject:
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withsmallint": True})
+    spaceconfig = {"objspace.std.withsmallint": True}
 
     def test_int_w(self):
         assert self.space.int_w(self.space.wrap(42)) == 42
@@ -228,7 +225,5 @@
 
 
 class AppTestSmallInt(AppTestInt):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.optimized_int_add" : True,
-                                       "objspace.std.withsmallint" : True})
+    spaceconfig = {"objspace.std.optimized_int_add" : True,
+                   "objspace.std.withsmallint" : True}
diff --git a/pypy/objspace/std/test/test_smalllongobject.py b/pypy/objspace/std/test/test_smalllongobject.py
--- a/pypy/objspace/std/test/test_smalllongobject.py
+++ b/pypy/objspace/std/test/test_smalllongobject.py
@@ -41,8 +41,7 @@
 
 
 class AppTestSmallLong(test_longobject.AppTestLong):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withsmalllong": True})
+    spaceconfig = {"objspace.std.withsmalllong": True}
 
     def test_sl_simple(self):
         import __pypy__
diff --git a/pypy/objspace/std/test/test_smalltupleobject.py b/pypy/objspace/std/test/test_smalltupleobject.py
--- a/pypy/objspace/std/test/test_smalltupleobject.py
+++ b/pypy/objspace/std/test/test_smalltupleobject.py
@@ -5,9 +5,9 @@
 from pypy.conftest import gettestobjspace
 
 class AppTestW_SmallTupleObject(AppTestW_TupleObject):
+    spaceconfig = {"objspace.std.withsmalltuple": True}
 
     def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withsmalltuple": True})
         cls.w_issmall = cls.space.appexec([], """():
             import __pypy__
             def issmall(obj):
@@ -56,9 +56,7 @@
         assert hash(a) != hash(c)
 
 class TestW_SmallTupleObject():
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withsmalltuple": True})
+    spaceconfig = {"objspace.std.withsmalltuple": True}
 
     def test_issmalltupleobject(self):
         w_tuple = self.space.newtuple([self.space.wrap(1), self.space.wrap(2)])
diff --git a/pypy/objspace/std/test/test_specialisedtupleobject.py b/pypy/objspace/std/test/test_specialisedtupleobject.py
--- a/pypy/objspace/std/test/test_specialisedtupleobject.py
+++ b/pypy/objspace/std/test/test_specialisedtupleobject.py
@@ -3,7 +3,7 @@
 from pypy.objspace.std.specialisedtupleobject import W_SpecialisedTupleObject
 from pypy.objspace.std.specialisedtupleobject import _specialisations
 from pypy.interpreter.error import OperationError
-from pypy.conftest import gettestobjspace, option
+from pypy.conftest import gettestobjspace
 from pypy.objspace.std.test import test_tupleobject
 from pypy.interpreter import gateway
 
@@ -13,9 +13,7 @@
 
 
 class TestW_SpecialisedTupleObject():
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withspecialisedtuple": True})
+    spaceconfig = {"objspace.std.withspecialisedtuple": True}
 
     def test_isspecialisedtupleobjectintint(self):
         w_tuple = self.space.newtuple([self.space.wrap(1), self.space.wrap(2)])
@@ -57,9 +55,9 @@
 
 
 class AppTestW_SpecialisedTupleObject:
+    spaceconfig = {"objspace.std.withspecialisedtuple": True}
 
     def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withspecialisedtuple": True})
         def forbid_delegation(space, w_tuple):
             def delegation_forbidden():
                 # haaaack
@@ -69,7 +67,7 @@
                 raise OperationError(space.w_ReferenceError, w_tuple)
             w_tuple.delegating = delegation_forbidden
             return w_tuple
-        if option.runappdirect:
+        if cls.option.runappdirect:
             cls.w_forbid_delegation = lambda self, x: x
             cls.test_delegation = lambda self: skip("runappdirect")
         else:
diff --git a/pypy/objspace/std/test/test_strbufobject.py b/pypy/objspace/std/test/test_strbufobject.py
--- a/pypy/objspace/std/test/test_strbufobject.py
+++ b/pypy/objspace/std/test/test_strbufobject.py
@@ -1,12 +1,9 @@
 import py
 
 from pypy.objspace.std.test import test_stringobject
-from pypy.conftest import gettestobjspace
 
 class AppTestStringObject(test_stringobject.AppTestStringObject):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withstrbuf": True})
+    spaceconfig = {"objspace.std.withstrbuf": True}
 
     def test_basic(self):
         import __pypy__
diff --git a/pypy/objspace/std/test/test_stringobject.py b/pypy/objspace/std/test/test_stringobject.py
--- a/pypy/objspace/std/test/test_stringobject.py
+++ b/pypy/objspace/std/test/test_stringobject.py
@@ -1,8 +1,3 @@
-from pypy.objspace.std import stringobject
-from pypy.objspace.std.stringobject import W_StringObject
-from pypy.conftest import gettestobjspace
-
-
 class TestW_StringObject:
 
     def teardown_method(self, method):
@@ -776,14 +771,11 @@
         raises(TypeError, len, iter(iterable))
 
 class AppTestPrebuilt(AppTestStringObject):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withprebuiltchar": True})
+    spaceconfig = {"objspace.std.withprebuiltchar": True}
 
 class AppTestShare(AppTestStringObject):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.sharesmallstr": True})
+    spaceconfig = {"objspace.std.sharesmallstr": True}
 
 class AppTestPrebuiltShare(AppTestStringObject):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withprebuiltchar": True,
-                                       "objspace.std.sharesmallstr": True})
+    spaceconfig = {"objspace.std.withprebuiltchar": True,
+                   "objspace.std.sharesmallstr": True}
diff --git a/pypy/objspace/std/test/test_strjoinobject.py b/pypy/objspace/std/test/test_strjoinobject.py
--- a/pypy/objspace/std/test/test_strjoinobject.py
+++ b/pypy/objspace/std/test/test_strjoinobject.py
@@ -1,12 +1,7 @@
-import py
-
 from pypy.objspace.std.test import test_stringobject
-from pypy.conftest import gettestobjspace
 
 class AppTestStringObject(test_stringobject.AppTestStringObject):
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withstrjoin": True})
+    spaceconfig = {"objspace.std.withstrjoin": True}
 
     def test_basic(self):
         import __pypy__
diff --git a/pypy/objspace/std/test/test_strsliceobject.py b/pypy/objspace/std/test/test_strsliceobject.py
--- a/pypy/objspace/std/test/test_strsliceobject.py
+++ b/pypy/objspace/std/test/test_strsliceobject.py
@@ -1,14 +1,13 @@
 import py
 
 from pypy.objspace.std.test import test_stringobject
-from pypy.conftest import gettestobjspace
 from pypy.interpreter import gateway
 from pypy.objspace.std.strsliceobject import W_StringSliceObject
 
 class AppTestStringObject(test_stringobject.AppTestStringObject):
+    space_config = {"objspace.std.withstrslice": True}
 
     def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withstrslice": True})
         def not_forced(space, w_s):
             return space.wrap(isinstance(w_s, W_StringSliceObject) and
                               (w_s.start != 0 or w_s.stop != len(w_s.str)))
diff --git a/pypy/objspace/std/test/test_typeobject.py b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -1,6 +1,5 @@
 from pypy.objspace.std.model import W_Object
 from pypy.objspace.std.stdtypedef import StdTypeDef
-from pypy.conftest import gettestobjspace
 
 from pypy.objspace.std.typeobject import W_TypeObject
 from pypy.interpreter.gateway import interp2app
@@ -1064,9 +1063,7 @@
         assert A.x == 5
 
 class AppTestMutableBuiltintypes:
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.mutable_builtintypes": True})
+    spaceconfig = {"objspace.std.mutable_builtintypes": True}
 
     def test_del_type_mro(self):
         del type.mro
@@ -1098,10 +1095,7 @@
         assert "run-time error" in RuntimeError.__doc__
 
 class AppTestGetattributeShortcut:
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(
-                        **{"objspace.std.getattributeshortcut": True})
+    spaceconfig = {"objspace.std.getattributeshortcut": True}
 
     def test_reset_logic(self):
         class X(object):
@@ -1142,10 +1136,7 @@
         assert y.x == 'GA2'
 
 class TestNewShortcut:
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(
-                        **{"objspace.std.newshortcut": True})   
+    spaceconfig = {"objspace.std.newshortcut": True}
 
     def test_mechanics(self):
         space = self.space
@@ -1184,10 +1175,7 @@
 
 
 class AppTestNewShortcut:
-
-    def setup_class(cls):
-        cls.space = gettestobjspace(
-                        **{"objspace.std.newshortcut": True})
+    spaceconfig = {"objspace.std.newshortcut": True}
 
     def test_reset_logic(self):
         class X(object):
diff --git a/pypy/objspace/std/test/test_unicodeobject.py b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -1,6 +1,5 @@
 import py
 import sys
-from pypy.conftest import gettestobjspace
 
 class TestUnicodeObject:
 
@@ -45,9 +44,9 @@
         
 
 class AppTestUnicodeString:
+    spaceconfig = dict(usemodules=('unicodedata',))
+
     def setup_class(cls):
-        space = gettestobjspace(usemodules=('unicodedata',))
-        cls.space = space
         cls.w_version_info = cls.space.wrap(sys.version_info)
 
     def test_addition(self):
diff --git a/pypy/objspace/std/test/test_userobject.py b/pypy/objspace/std/test/test_userobject.py
--- a/pypy/objspace/std/test/test_userobject.py
+++ b/pypy/objspace/std/test/test_userobject.py
@@ -4,12 +4,10 @@
 
 
 class AppTestUserObject:
-    OPTIONS = {}    # for test_builtinshortcut.py
+    spaceconfig = {}
 
     def setup_class(cls):
-        from pypy import conftest
-        cls.space = conftest.gettestobjspace(**cls.OPTIONS)
-        cls.w_runappdirect = cls.space.wrap(bool(conftest.option.runappdirect))
+        cls.w_runappdirect = cls.space.wrap(bool(cls.option.runappdirect))
         def rand(space):
             import random
             return space.wrap(random.randrange(0, 5))
@@ -276,18 +274,15 @@
 
 
 class AppTestWithMultiMethodVersion2(AppTestUserObject):
-    OPTIONS = {}    # for test_builtinshortcut.py
+    spaceconfig = {}
 
     def setup_class(cls):
-        from pypy import conftest
         from pypy.objspace.std import multimethod
 
         cls.prev_installer = multimethod.Installer
         multimethod.Installer = multimethod.InstallerVersion2
-        if conftest.option.runappdirect:
+        if cls.option.runappdirect:
             py.test.skip("Cannot run different installers when runappdirect")
-        config = conftest.make_config(conftest.option, **cls.OPTIONS)
-        cls.space = conftest.maketestobjspace(config)
 
     def teardown_class(cls):
         from pypy.objspace.std import multimethod
@@ -295,7 +290,7 @@
 
 
 class AppTestWithGetAttributeShortcut(AppTestUserObject):
-    OPTIONS = {"objspace.std.getattributeshortcut": True}
+    spaceconfig = {"objspace.std.getattributeshortcut": True}
 
 
 class AppTestDescriptorWithGetAttributeShortcut(
@@ -303,4 +298,4 @@
     # for the individual tests see
     # ====> ../../test/test_descriptor.py
 
-    OPTIONS = {"objspace.std.getattributeshortcut": True}
+    spaceconfig = {"objspace.std.getattributeshortcut": True}
diff --git a/pypy/objspace/std/test/test_versionedtype.py b/pypy/objspace/std/test/test_versionedtype.py
--- a/pypy/objspace/std/test/test_versionedtype.py
+++ b/pypy/objspace/std/test/test_versionedtype.py
@@ -1,9 +1,7 @@
 from pypy.objspace.std.test import test_typeobject
-from pypy.conftest import gettestobjspace
 
 class TestVersionedType(test_typeobject.TestTypeObject):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withtypeversion": True})
+    spaceconfig = {"objspace.std.withtypeversion": True}
 
     def get_three_classes(self):
         space = self.space
@@ -214,6 +212,5 @@
 
 
 class AppTestVersionedType(test_typeobject.AppTestTypeObject):
-    def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.withtypeversion": True})
+    spaceconfig = {"objspace.std.withtypeversion": True}
 


More information about the pypy-commit mailing list