Author: Amaury Forgeot d'Arc <[email protected]>
Branch: less-gettestobjspace
Changeset: r58618:3eb05cbcfc2b
Date: 2012-10-29 00:55 +0100
http://bitbucket.org/pypy/pypy/changeset/3eb05cbcfc2b/
Log: progress
diff --git a/pypy/module/_sre/test/test_app_sre.py
b/pypy/module/_sre/test/test_app_sre.py
--- a/pypy/module/_sre/test/test_app_sre.py
+++ b/pypy/module/_sre/test/test_app_sre.py
@@ -3,7 +3,6 @@
import py
from py.test import raises, skip
from pypy.interpreter.gateway import app2interp_temp
-from pypy.conftest import gettestobjspace, option
def init_app_test(cls, space):
cls.w_s = space.appexec([space.wrap(autopath.this_dir)],
@@ -94,8 +93,7 @@
class AppTestSreMatch:
- def setup_class(cls):
- cls.space = gettestobjspace(usemodules=('array', ))
+ spaceconfig = dict(usemodules=('array', ))
def test_copy(self):
import re
@@ -336,13 +334,10 @@
class AppTestGetlower:
+ spaceconfig = dict(usemodules=('_locale',))
def setup_class(cls):
# This imports support_test_sre as the global "s"
- try:
- cls.space = gettestobjspace(usemodules=('_locale',))
- except py.test.skip.Exception:
- cls.space = gettestobjspace(usemodules=('_rawffi',))
init_app_test(cls, cls.space)
def setup_method(self, method):
@@ -600,14 +595,11 @@
class AppTestOpcodes:
+ spaceconfig = dict(usemodules=('_locale',))
def setup_class(cls):
- if option.runappdirect:
+ if cls.option.runappdirect:
py.test.skip("can only be run on py.py: _sre opcodes don't match")
- try:
- cls.space = gettestobjspace(usemodules=('_locale',))
- except py.test.skip.Exception:
- cls.space = gettestobjspace(usemodules=('_rawffi',))
# This imports support_test_sre as the global "s"
init_app_test(cls, cls.space)
diff --git a/pypy/module/struct/test/test_struct.py
b/pypy/module/struct/test/test_struct.py
--- a/pypy/module/struct/test/test_struct.py
+++ b/pypy/module/struct/test/test_struct.py
@@ -3,18 +3,17 @@
"""
import py
-from pypy.conftest import gettestobjspace
from pypy.rlib.rstruct.nativefmttable import native_is_bigendian
class AppTestStruct(object):
+ spaceconfig = dict(usemodules=['struct'])
def setup_class(cls):
"""
Create a space with the struct module and import it for use by the
tests.
"""
- cls.space = gettestobjspace(usemodules=['struct'])
cls.w_struct = cls.space.appexec([], """():
import struct
return struct
@@ -387,12 +386,9 @@
class AppTestStructBuffer(object):
+ spaceconfig = dict(usemodules=['struct', '__pypy__'])
def setup_class(cls):
- """
- Create a space with the struct and __pypy__ modules.
- """
- cls.space = gettestobjspace(usemodules=['struct', '__pypy__'])
cls.w_struct = cls.space.appexec([], """():
import struct
return struct
diff --git a/pypy/module/sys/test/test_sysmodule.py
b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -1,8 +1,4 @@
# -*- coding: iso-8859-1 -*-
-import autopath
-from pypy.conftest import option, gettestobjspace
-from py.test import raises
-from pypy.interpreter.gateway import app2interp_temp
import sys
def test_stdin_exists(space):
@@ -16,7 +12,7 @@
class AppTestAppSysTests:
def setup_class(cls):
- cls.w_appdirect = cls.space.wrap(option.runappdirect)
+ cls.w_appdirect = cls.space.wrap(cls.option.runappdirect)
cls.w_filesystemenc = cls.space.wrap(sys.getfilesystemencoding())
def test_sys_in_modules(self):
@@ -130,7 +126,7 @@
class AppTestSysModulePortedFromCPython:
def setup_class(cls):
- cls.w_appdirect = cls.space.wrap(option.runappdirect)
+ cls.w_appdirect = cls.space.wrap(cls.option.runappdirect)
def test_original_displayhook(self):
import sys, cStringIO, __builtin__
@@ -560,8 +556,7 @@
assert frames[0].f_code.co_name in ('f', '?')
class AppTestCurrentFramesWithThread(AppTestCurrentFrames):
- def setup_class(cls):
- cls.space = gettestobjspace(usemodules=('thread',))
+ spaceconfig = dict(usemodules=('thread',))
def test_current_frames(self):
import sys
@@ -601,7 +596,7 @@
class AppTestSysExcInfoDirect:
def setup_method(self, meth):
- self.checking = not option.runappdirect
+ self.checking = not self.option.runappdirect
if self.checking:
self.seen = []
from pypy.module.sys import vm
@@ -715,5 +710,4 @@
class AppTestSysExcInfoDirectCallMethod(AppTestSysExcInfoDirect):
- def setup_class(cls):
- cls.space = gettestobjspace(**{"objspace.opcodes.CALL_METHOD": True})
+ spaceconfig = {"objspace.opcodes.CALL_METHOD": True}
diff --git a/pypy/module/termios/test/test_termios.py
b/pypy/module/termios/test/test_termios.py
--- a/pypy/module/termios/test/test_termios.py
+++ b/pypy/module/termios/test/test_termios.py
@@ -1,7 +1,6 @@
import py
import sys
-from pypy.conftest import gettestobjspace
from pypy.tool.autopath import pypydir
from pypy.tool.udir import udir
@@ -106,8 +105,9 @@
child.expect('ok!')
class AppTestTermios(object):
+ spaceconfig = dict(usemodules=['termios'])
+
def setup_class(cls):
- cls.space = gettestobjspace(usemodules=['termios'])
d = {}
import termios
for name in dir(termios):
diff --git a/pypy/module/thread/test/support.py
b/pypy/module/thread/test/support.py
--- a/pypy/module/thread/test/support.py
+++ b/pypy/module/thread/test/support.py
@@ -1,6 +1,5 @@
import py
import time, gc, thread, os
-from pypy.conftest import gettestobjspace, option
from pypy.interpreter.gateway import ObjSpace, W_Root, interp2app_temp
from pypy.module.thread import gil
@@ -30,12 +29,10 @@
thread.start_new_thread(kill, ())
class GenericTestThread:
+ spaceconfig = dict(usemodules=('thread', 'time', 'signal'))
def setup_class(cls):
- space = gettestobjspace(usemodules=('thread', 'time', 'signal'))
- cls.space = space
-
- if option.runappdirect:
+ if cls.option.runappdirect:
def plain_waitfor(self, condition, delay=1):
adaptivedelay = 0.04
limit = time.time() + NORMAL_TIMEOUT * delay
@@ -49,10 +46,12 @@
cls.w_waitfor = plain_waitfor
else:
- cls.w_waitfor = space.wrap(lambda self, condition, delay=1:
waitfor(space, condition, delay))
- cls.w_busywait = space.appexec([], """():
+ cls.w_waitfor = cls.space.wrap(
+ lambda self, condition, delay=1: waitfor(cls.space, condition,
delay))
+ cls.w_busywait = cls.space.appexec([], """():
import time
return time.sleep
""")
- cls.w_timeout_killer = space.wrap(lambda self, *args, **kwargs:
timeout_killer(*args, **kwargs))
+ cls.w_timeout_killer = cls.space.wrap(
+ lambda self, *args, **kwargs: timeout_killer(*args, **kwargs))
diff --git a/pypy/module/thread/test/test_fork.py
b/pypy/module/thread/test/test_fork.py
--- a/pypy/module/thread/test/test_fork.py
+++ b/pypy/module/thread/test/test_fork.py
@@ -1,5 +1,3 @@
-import py, sys
-from pypy.conftest import gettestobjspace
from pypy.module.thread.test.support import GenericTestThread
class AppTestFork(GenericTestThread):
diff --git a/pypy/module/time/test/test_time.py
b/pypy/module/time/test/test_time.py
--- a/pypy/module/time/test/test_time.py
+++ b/pypy/module/time/test/test_time.py
@@ -1,24 +1,21 @@
-from pypy.conftest import gettestobjspace
import time
-def setup_module(mod):
- mod.space = gettestobjspace(usemodules=['time'])
+class TestTime:
+ spaceconfig = dict(usemodules=['time'])
-class TestTime:
-
- def test_clock(self):
+ def test_clock(self, space):
t0 = time.clock()
w_t1 = space.appexec([], """(): import time; return time.clock()""")
t2 = time.clock()
assert t0 <= space.unwrap(w_t1) <= t2
- def test_time(self):
+ def test_time(self, space):
t0 = time.time()
w_t1 = space.appexec([], """(): import time; return time.time()""")
t2 = time.time()
assert t0 <= space.unwrap(w_t1) <= t2
- def test_sleep(self):
+ def test_sleep(self, space):
w_sleep = space.appexec([], """(): import time; return time.sleep""")
t0 = time.time()
space.call_function(w_sleep, space.wrap(0.3))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit