Author: Amaury Forgeot d'Arc <[email protected]>
Branch: less-gettestobjspace
Changeset: r58619:18619c1f1118
Date: 2012-10-29 01:03 +0100
http://bitbucket.org/pypy/pypy/changeset/18619c1f1118/

Log:    progress

diff --git a/pypy/module/_warnings/test/test_warnings.py 
b/pypy/module/_warnings/test/test_warnings.py
--- a/pypy/module/_warnings/test/test_warnings.py
+++ b/pypy/module/_warnings/test/test_warnings.py
@@ -1,11 +1,5 @@
-import py
-import sys
-from pypy.conftest import gettestobjspace
-
 class AppTestWarnings:
-    def setup_class(cls):
-        space = gettestobjspace(usemodules=('_warnings',))
-        cls.space = space
+    spaceconfig = dict(usemodules=('_warnings',))
 
     def test_defaults(self):
         import _warnings
diff --git a/pypy/module/_weakref/test/test_weakref.py 
b/pypy/module/_weakref/test/test_weakref.py
--- a/pypy/module/_weakref/test/test_weakref.py
+++ b/pypy/module/_weakref/test/test_weakref.py
@@ -1,9 +1,5 @@
-from pypy.conftest import gettestobjspace
-
 class AppTestWeakref(object):
-    def setup_class(cls):
-        space = gettestobjspace(usemodules=('_weakref',))
-        cls.space = space
+    spaceconfig = dict(usemodules=('_weakref',))
                     
     def test_simple(self):
         import _weakref, gc
@@ -304,9 +300,7 @@
 
 
 class AppTestProxy(object):
-    def setup_class(cls):
-        space = gettestobjspace(usemodules=('_weakref',))
-        cls.space = space
+    spaceconfig = dict(usemodules=('_weakref',))
                     
     def test_simple(self):
         import _weakref, gc
diff --git a/pypy/module/unicodedata/test/test_unicodedata.py 
b/pypy/module/unicodedata/test/test_unicodedata.py
--- a/pypy/module/unicodedata/test/test_unicodedata.py
+++ b/pypy/module/unicodedata/test/test_unicodedata.py
@@ -1,13 +1,8 @@
-from py.test import raises, skip
 from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin
-from pypy.conftest import gettestobjspace
-
 from pypy.module.unicodedata import unicodedb_3_2_0, unicodedb_5_2_0
 
 class AppTestUnicodeData:
-    def setup_class(cls):
-        space = gettestobjspace(usemodules=('unicodedata',))
-        cls.space = space
+    spaceconfig = dict(usemodules=('unicodedata',))
 
     def test_hangul_syllables(self):
         import unicodedata
diff --git a/pypy/module/zipimport/test/test_undocumented.py 
b/pypy/module/zipimport/test/test_undocumented.py
--- a/pypy/module/zipimport/test/test_undocumented.py
+++ b/pypy/module/zipimport/test/test_undocumented.py
@@ -6,7 +6,6 @@
 import shutil
 import time
 import zipfile
-from pypy.conftest import gettestobjspace
 
 TESTFN = '@test'
 
@@ -18,10 +17,9 @@
                                ])
 
 class AppTestZipImport:
+    spaceconfig = dict(usemodules=['zipimport', 'rctime', 'struct'])
     def setup_class(cls):
-        space = gettestobjspace(usemodules=['zipimport', 'rctime', 'struct'])
-        cls.space = space
-        cls.w_created_paths = space.wrap(created_paths)
+        cls.w_created_paths = cls.space.wrap(created_paths)
     
     def w_temp_zipfile(self, created_paths, source=True, bytecode=True):
         """Create a temporary zip file for testing.
diff --git a/pypy/module/zipimport/test/test_zipimport.py 
b/pypy/module/zipimport/test/test_zipimport.py
--- a/pypy/module/zipimport/test/test_zipimport.py
+++ b/pypy/module/zipimport/test/test_zipimport.py
@@ -1,5 +1,4 @@
 
-from pypy.conftest import gettestobjspace
 import marshal
 import py, os
 import time
@@ -15,8 +14,10 @@
     cpy's regression tests
     """
     compression = ZIP_STORED
+    spaceconfig = dict(usemodules=['zipimport', 'rctime', 'struct'])
     pathsep = os.path.sep
     
+    @classmethod
     def make_pyc(cls, space, co, mtime):
         data = marshal.dumps(co)
         if type(mtime) is type(0.0):
@@ -33,7 +34,8 @@
             s.write(imp.get_magic())
         pyc = s.getvalue() + struct.pack("<i", int(mtime)) + data
         return pyc
-    make_pyc = classmethod(make_pyc)
+
+    @classmethod
     def make_class(cls):
         # XXX: this is (mostly) wrong: .compile() compiles the code object
         # using the host python compiler, but then in the tests we load it
@@ -45,13 +47,8 @@
         def get_file():
             return __file__
         """).compile()
-
-        if cls.compression == ZIP_DEFLATED:
-            space = gettestobjspace(usemodules=['zipimport', 'zlib', 'rctime', 
'struct'])
-        else:
-            space = gettestobjspace(usemodules=['zipimport', 'rctime', 
'struct'])
             
-        cls.space = space
+        space = cls.space
         tmpdir = udir.ensure('zipimport_%s' % cls.__name__, dir=1)
         now = time.time()
         cls.w_now = space.wrap(now)
@@ -64,7 +61,6 @@
         cls.w_tmpzip = space.wrap(str(ziptestmodule))
         cls.w_co = space.wrap(co)
         cls.tmpdir = tmpdir
-    make_class = classmethod(make_class)
 
     def setup_class(cls):
         cls.make_class()
@@ -357,6 +353,7 @@
 
 class AppTestZipimportDeflated(AppTestZipimport):
     compression = ZIP_DEFLATED
+    spaceconfig = dict(usemodules=['zipimport', 'zlib', 'rctime', 'struct'])
 
     def setup_class(cls):
         try:
diff --git a/pypy/module/zlib/test/test_zlib.py 
b/pypy/module/zlib/test/test_zlib.py
--- a/pypy/module/zlib/test/test_zlib.py
+++ b/pypy/module/zlib/test/test_zlib.py
@@ -13,8 +13,6 @@
 except ImportError:
     import py; py.test.skip("no zlib C library on this machine")
  
-from pypy.conftest import gettestobjspace
-
 def test_unsigned_to_signed_32bit():
     assert interp_zlib.unsigned_to_signed_32bit(123) == 123
     assert interp_zlib.unsigned_to_signed_32bit(2**31) == -2**31
@@ -22,6 +20,8 @@
 
 
 class AppTestZlib(object):
+    spaceconfig = dict(usemodules=['zlib'])
+
     def setup_class(cls):
         """
         Create a space with the zlib module and import it for use by the tests.
@@ -29,11 +29,7 @@
         compression and decompression tests have a little real data to assert
         against.
         """
-        cls.space = gettestobjspace(usemodules=['zlib'])
-        cls.w_zlib = cls.space.appexec([], """():
-            import zlib
-            return zlib
-        """)
+        cls.w_zlib = cls.space.getbuiltinmodule('zlib')
         expanded = 'some bytes which will be compressed'
         cls.w_expanded = cls.space.wrap(expanded)
         cls.w_compressed = cls.space.wrap(zlib.compress(expanded))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to