[pypy-svn] r74365 - in pypy/branch/py12/pypy: . interpreter/test lib/distributed/test module/_sre/test module/gc/test module/imp/test tool/pytest/test tool/test
hpk at codespeak.net
hpk at codespeak.net
Tue May 4 21:34:05 CEST 2010
Author: hpk
Date: Tue May 4 21:34:03 2010
New Revision: 74365
Added:
pypy/branch/py12/pypy/tool/pytest/test/test_pytestsupport.py
- copied, changed from r74323, pypy/branch/py12/pypy/tool/test/test_pytestsupport.py
Removed:
pypy/branch/py12/pypy/tool/test/test_pytestsupport.py
Modified:
pypy/branch/py12/pypy/conftest.py
pypy/branch/py12/pypy/interpreter/test/test_zzpickle_and_slow.py
pypy/branch/py12/pypy/lib/distributed/test/test_distributed.py
pypy/branch/py12/pypy/module/_sre/test/test_app_sre.py
pypy/branch/py12/pypy/module/gc/test/test_gc.py
pypy/branch/py12/pypy/module/imp/test/test_import.py
pypy/branch/py12/pypy/tool/pytest/test/test_appsupport.py
Log:
Various bits to make buildbot applevel tests run
* extended conftest.py mechanism for space configuration:
defining "spaceconfig = dict-instance" on a test class
will instantiate (or skip) an according space object.
* fixes related to the fact that py.test since 1.2
adheres to the convention of running teardown_* functions
even if the corresponding setup_* failed.
* more tests for pytestsupport itself
Modified: pypy/branch/py12/pypy/conftest.py
==============================================================================
--- pypy/branch/py12/pypy/conftest.py (original)
+++ pypy/branch/py12/pypy/conftest.py Tue May 4 21:34:03 2010
@@ -43,7 +43,8 @@
help="set up tests to use specified platform as compile/run target")
def pytest_funcarg__space(request):
- return gettestobjspace()
+ spaceconfig = getattr(request.cls, 'spaceconfig', {})
+ return gettestobjspace(**spaceconfig)
_SPACECACHE={}
def gettestobjspace(name=None, **kwds):
@@ -93,6 +94,14 @@
space.eq_w = appsupport.eq_w.__get__(space)
return space
+def pytest_runtest_setup(item):
+ if isinstance(item, PyPyTestFunction):
+ appclass = item.getparent(PyPyClassCollector)
+ if appclass is not None:
+ spaceconfig = getattr(appclass.obj, 'spaceconfig', None)
+ if spaceconfig:
+ appclass.obj.space = gettestobjspace(**spaceconfig)
+
class TinyObjSpace(object):
def __init__(self, **kwds):
import sys
@@ -408,11 +417,17 @@
class PyPyClassCollector(py.test.collect.Class):
def setup(self):
cls = self.obj
- cls.space = LazyObjSpaceGetter()
+ if not hasattr(cls, 'spaceconfig'):
+ cls.space = LazyObjSpaceGetter()
+ else:
+ assert hasattr(cls, 'space') # set by pytest_runtest_setup
super(PyPyClassCollector, self).setup()
+
+class IntInstanceCollector(py.test.collect.Instance):
+ Function = IntTestFunction
class IntClassCollector(PyPyClassCollector):
- Function = IntTestFunction
+ Instance = IntInstanceCollector
def _haskeyword(self, keyword):
return keyword == 'interplevel' or \
Modified: pypy/branch/py12/pypy/interpreter/test/test_zzpickle_and_slow.py
==============================================================================
--- pypy/branch/py12/pypy/interpreter/test/test_zzpickle_and_slow.py (original)
+++ pypy/branch/py12/pypy/interpreter/test/test_zzpickle_and_slow.py Tue May 4 21:34:03 2010
@@ -73,10 +73,8 @@
space.wrap('restore_top_frame'))
class AppTestInterpObjectPickling:
-
+ pytestmark = py.test.mark.skipif("config.option.runappdirect")
def setup_class(cls):
- if conftest.option.runappdirect:
- py.test.skip("not for py.test -A")
_attach_helpers(cls.space)
def teardown_class(cls):
Modified: pypy/branch/py12/pypy/lib/distributed/test/test_distributed.py
==============================================================================
--- pypy/branch/py12/pypy/lib/distributed/test/test_distributed.py (original)
+++ pypy/branch/py12/pypy/lib/distributed/test/test_distributed.py Tue May 4 21:34:03 2010
@@ -94,9 +94,11 @@
assert len(item) == 11
class AppTestDistributedTasklets(object):
+ spaceconfig = {"objspace.std.withtproxy": True,
+ "objspace.usemodules._stackless": True}
def setup_class(cls):
- cls.space = gettestobjspace(**{"objspace.std.withtproxy": True,
- "usemodules":("_stackless",)})
+ #cls.space = gettestobjspace(**{"objspace.std.withtproxy": True,
+ # "usemodules":("_stackless",)})
cls.w_test_env = cls.space.appexec([], """():
from distributed import test_env
return test_env
Modified: pypy/branch/py12/pypy/module/_sre/test/test_app_sre.py
==============================================================================
--- pypy/branch/py12/pypy/module/_sre/test/test_app_sre.py (original)
+++ pypy/branch/py12/pypy/module/_sre/test/test_app_sre.py Tue May 4 21:34:03 2010
@@ -1,5 +1,6 @@
"""Regular expression tests specific to _sre.py and accumulated during TDD."""
import autopath
+import py
from py.test import raises, skip
from pypy.interpreter.gateway import app2interp_temp
from pypy.conftest import gettestobjspace, option
Modified: pypy/branch/py12/pypy/module/gc/test/test_gc.py
==============================================================================
--- pypy/branch/py12/pypy/module/gc/test/test_gc.py (original)
+++ pypy/branch/py12/pypy/module/gc/test/test_gc.py Tue May 4 21:34:03 2010
@@ -1,4 +1,5 @@
from pypy.conftest import gettestobjspace
+import py
class AppTestGC(object):
def test_collect(self):
@@ -76,9 +77,10 @@
assert gc.isenabled()
class AppTestGcDumpHeap(object):
+ pytestmark = py.test.mark.xfail(run=False)
+
def setup_class(cls):
import py
- py.test.skip("Disabled")
from pypy.tool.udir import udir
from pypy.rlib import rgc
class X(object):
Modified: pypy/branch/py12/pypy/module/imp/test/test_import.py
==============================================================================
--- pypy/branch/py12/pypy/module/imp/test/test_import.py (original)
+++ pypy/branch/py12/pypy/module/imp/test/test_import.py Tue May 4 21:34:03 2010
@@ -920,16 +920,15 @@
sys.path_hooks.pop()
class AppTestNoPycFile(object):
- usepycfiles = False
- lonepycfiles = False
-
+ spaceconfig = {
+ "objspace.usepycfiles": False,
+ "objspace.lonepycfiles": False
+ }
def setup_class(cls):
- cls.space = gettestobjspace(**{
- "objspace.usepycfiles": cls.usepycfiles,
- "objspace.lonepycfiles": cls.lonepycfiles,
- })
- cls.w_usepycfiles = cls.space.wrap(cls.usepycfiles)
- cls.w_lonepycfiles = cls.space.wrap(cls.lonepycfiles)
+ usepycfiles = cls.spaceconfig['objspace.usepycfiles']
+ lonepycfiles = cls.spaceconfig['objspace.lonepycfiles']
+ cls.w_usepycfiles = cls.space.wrap(usepycfiles)
+ cls.w_lonepycfiles = cls.space.wrap(lonepycfiles)
cls.saved_modules = _setup(cls.space)
def teardown_class(cls):
@@ -950,9 +949,13 @@
assert lone.__file__.endswith('lone.pyc')
class AppTestNoLonePycFile(AppTestNoPycFile):
- usepycfiles = True
- lonepycfiles = False
+ spaceconfig = {
+ "objspace.usepycfiles": True,
+ "objspace.lonepycfiles": False
+ }
class AppTestLonePycFile(AppTestNoPycFile):
- usepycfiles = True
- lonepycfiles = True
+ spaceconfig = {
+ "objspace.usepycfiles": True,
+ "objspace.lonepycfiles": True
+ }
Modified: pypy/branch/py12/pypy/tool/pytest/test/test_appsupport.py
==============================================================================
--- pypy/branch/py12/pypy/tool/pytest/test/test_appsupport.py (original)
+++ pypy/branch/py12/pypy/tool/pytest/test/test_appsupport.py Tue May 4 21:34:03 2010
@@ -1,4 +1,74 @@
+import sys
+import py
+import pypy
+pytest_plugins = "pytester"
+
+def setpypyconftest(testdir):
+ path = str(py.path.local(pypy.__file__).dirpath().dirpath())
+ testdir.makeconftest("""
+ import sys
+ sys.path.insert(0, %r)
+ from pypy.conftest import *
+ """ % path)
+
+def test_pypy_collection(testdir):
+ testdir.makepyfile("""
+ def test_func():
+ pass
+ class TestClassInt:
+ def test_method(self, space):
+ pass
+ class AppTestClass:
+ def test_method(self):
+ pass
+ """)
+ setpypyconftest(testdir)
+ result = testdir.runpytest("--collectonly")
+ assert result.ret == 0
+ result.stdout.fnmatch_lines([
+ "*IntTestFunction*test_func*",
+ "*IntClassCollector*TestClassInt*",
+ "*IntTestFunction*test_method*",
+ "*AppClassCollector*AppTestClass*",
+ "*AppTestMethod*",
+ ])
+
+class TestSpaceConfig:
+ def test_applevel_skipped_on_cpython_and_spaceconfig(self, testdir):
+ setpypyconftest(testdir)
+ testdir.makepyfile("""
+ class AppTestClass:
+ spaceconfig = {"objspace.usemodules._stackless": True}
+ def setup_class(cls):
+ assert 0
+ def test_applevel(self):
+ pass
+ """)
+ result = testdir.runpytest("-A")
+ assert result.ret == 0
+ if hasattr(sys, 'pypy_translation_info') and \
+ sys.pypy_translation_info.get('objspace.usemodules._stackless'):
+ result.stdout.fnmatch_lines(["*1 error*"])
+ else:
+ # setup_class didn't get called, otherwise it would error
+ result.stdout.fnmatch_lines(["*1 skipped*"])
+
+ def test_interp_spaceconfig(self, testdir):
+ setpypyconftest(testdir)
+ p = testdir.makepyfile("""
+ class TestClass:
+ spaceconfig = {"objspace.usemodules._stackless": False}
+ def setup_class(cls):
+ assert not cls.space.config.objspace.usemodules._stackless
+ def test_interp(self, space):
+ assert self.space is space
+ def test_interp2(self, space):
+ assert self.space is space
+ """)
+ result = testdir.runpytest(p)
+ assert result.ret == 0
+ result.stdout.fnmatch_lines(["*2 passed*"])
def app_test_raises():
info = raises(TypeError, id)
Copied: pypy/branch/py12/pypy/tool/pytest/test/test_pytestsupport.py (from r74323, pypy/branch/py12/pypy/tool/test/test_pytestsupport.py)
==============================================================================
--- pypy/branch/py12/pypy/tool/test/test_pytestsupport.py (original)
+++ pypy/branch/py12/pypy/tool/pytest/test/test_pytestsupport.py Tue May 4 21:34:03 2010
@@ -1,4 +1,3 @@
-import autopath
from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import app2interp_temp
from pypy.interpreter.argument import Arguments
More information about the Pypy-commit
mailing list