Read about our upcoming Code of Conduct on this issue

Commit 5126fdd7 authored by Ronan Lamy's avatar Ronan Lamy
Browse files

Kill unused AppTestFunction

parent d88a8a0fb88a
......@@ -114,8 +114,8 @@ def pytest_pycollect_makemodule(path, parent):
return PyPyModule(path, parent)
def is_applevel(item):
from pypy.tool.pytest.apptest import AppTestFunction
return isinstance(item, AppTestFunction)
from pypy.tool.pytest.apptest import AppTestMethod
return isinstance(item, AppTestMethod)
def pytest_collection_modifyitems(config, items):
if config.getoption('runappdirect') or config.getoption('direct_apptest'):
......@@ -145,8 +145,6 @@ class PyPyModule(pytest.Module):
def funcnamefilter(self, name):
if name.startswith('test_'):
return self.accept_regular_test()
if name.startswith('app_test_'):
return True
return False
def classnamefilter(self, name):
......@@ -161,13 +159,6 @@ class PyPyModule(pytest.Module):
if name.startswith('AppTest'):
from pypy.tool.pytest.apptest import AppClassCollector
return AppClassCollector(name, parent=self)
elif hasattr(obj, 'func_code') and self.funcnamefilter(name):
if name.startswith('app_test_'):
assert not obj.func_code.co_flags & 32, \
"generator app level functions? you must be joking"
from pypy.tool.pytest.apptest import AppTestFunction
return AppTestFunction(name, parent=self)
return super(PyPyModule, self).makeitem(name, obj)
def skip_on_missing_buildoption(**ropts):
......
......@@ -12,4 +12,3 @@ def test_mangle():
assert mangle("__foo", "__Bar") == "_Bar__foo"
assert mangle("__foo", "___") == "__foo"
assert mangle("___foo", "__Bar") == "_Bar___foo"
......@@ -98,10 +98,6 @@ def test_applevel_class(space, applevel_temp = applevel_temp):
w_clsattr = space.getattr(c, space.wrap('attr'))
assert space.eq_w(w_clsattr, space.wrap(17))
def app_test_something_at_app_level():
x = 2
assert x/2 == 1
class AppTestMethods:
def test_some_app_test_method(self):
assert 2 == 2
......
# Collects and executes application-level tests.
#
# Classes which names start with "AppTest", or function which names
# start with "app_test*" are not executed by the host Python, but
# Classes which names start with "AppTest"
# are not executed by the host Python, but
# by an interpreted pypy object space.
#
# ...unless the -A option ('runappdirect') is passed.
......@@ -21,7 +21,7 @@ class AppError(Exception):
self.excinfo = excinfo
class AppTestFunction(py.test.collect.Function):
class AppTestMethod(py.test.collect.Function):
def _prunetraceback(self, traceback):
return traceback
......@@ -40,20 +40,10 @@ class AppTestFunction(py.test.collect.Function):
raise AppError, AppError(appexcinfo), tb
raise
def runtest(self):
target = self.obj
if self.config.option.runappdirect:
return target()
space = gettestobjspace(**{'objspace.std.reinterpretasserts': True})
filename = self._getdynfilename(target)
func = app2interp_temp(target, filename=filename)
print "executing", func
self.execute_appex(space, func, space)
def repr_failure(self, excinfo):
if excinfo.errisinstance(AppError):
excinfo = excinfo.value.excinfo
return super(AppTestFunction, self).repr_failure(excinfo)
return super(AppTestMethod, self).repr_failure(excinfo)
def _getdynfilename(self, func):
code = getattr(func, 'im_func', func).func_code
......@@ -66,8 +56,6 @@ class AppTestFunction(py.test.collect.Function):
if hasattr(self, 'space'):
self.space.getexecutioncontext()._run_finalizers_now()
class AppTestMethod(AppTestFunction):
def setup(self):
super(AppTestMethod, self).setup()
instance = self.parent.obj
......
class AppTestTest:
class AppTestTest:
def test_app_method(self):
assert 42 == 41
assert 42 == 41
def app_test_app_func():
assert 41 == 42
def test_interp_func(space):
assert space.is_true(space.w_None)
def test_interp_func(space):
assert space.is_true(space.w_None)
def test_interp_reinterpret(space):
a = 1
assert a == 2
class TestInterpTest:
def test_interp_method(self):
assert self.space.is_true(self.space.w_False)
def app_test_raises_in_statement():
raises(ValueError, """
y = x # name error
""")
def app_test_raises_something():
int("hallo")
def app_test_raises_wrong1():
raises(SyntaxError, 'int("hello")')
def app_test_raises_wrong2():
raises(SyntaxError, int, "hello")
def app_test_raises_doesnt():
raises(ValueError, int, 3)
def app_test_skip():
skip("skipped test")
class TestInterpTest:
def test_interp_method(self):
assert self.space.is_true(self.space.w_False)
def test_something(space):
assert space.w_None is space.w_None
def test_something(space):
assert space.w_None is space.w_None
def app_test_something():
assert 42 == 42
class AppTestSomething:
def test_method_app(self):
assert 23 == 23
class AppTestSomething:
def test_method_app(self):
assert 23 == 23
class TestSomething:
def test_method(self):
assert self.space
def test_method(self):
assert self.space
......@@ -76,8 +76,6 @@ def test_spaceconfig_param(testdir):
def test_applevel_raises_simple_display(testdir):
setpypyconftest(testdir)
p = testdir.makepyfile("""
def app_test_raises():
raises(ValueError, x)
class AppTestRaises:
def test_func(self):
raises (ValueError, x)
......@@ -86,7 +84,6 @@ def test_applevel_raises_simple_display(testdir):
result = testdir.runpytest(p, "-s")
assert result.ret == 1
result.stdout.fnmatch_lines([
"*E*application-level*NameError*x*not defined",
"*test_func(self)*",
">*raises*ValueError*",
"*E*application-level*NameError*x*not defined",
......@@ -98,37 +95,6 @@ def test_applevel_raises_simple_display(testdir):
"*E*application-level*NameError*x*not defined",
])
def test_applevel_raises_display(testdir):
setpypyconftest(testdir)
p = testdir.makepyfile("""
def app_test_raises():
raises(ValueError, "x")
pass
""")
result = testdir.runpytest(p, "-s")
assert result.ret == 1
result.stdout.fnmatch_lines([
"*E*application-level*NameError*x*not defined",
])
result = testdir.runpytest(p) # this time we may run the pyc file
assert result.ret == 1
result.stdout.fnmatch_lines([
"*E*application-level*NameError*x*not defined",
])
def test_applevel_raise_keyerror(testdir):
setpypyconftest(testdir)
p = testdir.makepyfile("""
def app_test_raises():
raise KeyError(42)
pass
""")
result = testdir.runpytest(p, "-s")
assert result.ret == 1
result.stdout.fnmatch_lines([
"*E*application-level*KeyError*42*",
])
def test_apptest_raise(testdir):
setpypyconftest(testdir)
p = testdir.makepyfile(apptest_raise="""
......@@ -168,14 +134,3 @@ def test_apptest_fail_rewrite(testdir):
"*E*- foo*",
"*E*+ bar*",
])
def app_test_raises():
info = raises(TypeError, id)
assert info.type is TypeError
assert isinstance(info.value, TypeError)
x = 43
info = raises(ZeroDivisionError, "x/0")
assert info.type is ZeroDivisionError
assert isinstance(info.value, ZeroDivisionError)
......@@ -16,7 +16,6 @@ class TestPyPyTests:
def test_selection_by_keyword_app(self, testdir):
sorter = testdir.inline_run("-m", "applevel", innertest)
passed, skipped, failed = sorter.listoutcomes()
assert len(passed) == 2
assert len(passed) == 1
assert not skipped and not failed
assert "app_test_something" in passed[0].nodeid
assert "test_method_app" in passed[1].nodeid
assert "test_method_app" in passed[0].nodeid
......@@ -43,27 +43,6 @@ def test_myexception(space):
else:
assert False, "got no exception!"
def app_test_exception():
try:
raise AssertionError("42")
except AssertionError:
pass
else:
raise AssertionError("app level AssertionError mixup!")
def app_test_exception_with_message():
try:
assert 0, "Failed"
except AssertionError as e:
assert e.msg == "Failed"
def app_test_comparison():
try:
assert 3 > 4
except AssertionError as e:
assert "3 > 4" in e.msg
def test_appexecinfo(space):
try:
space.appexec([], "(): raise ValueError")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment