diff options
author | Ronan Lamy <ronan.lamy@gmail.com> | 2019-11-05 20:50:55 +0000 |
---|---|---|
committer | Ronan Lamy <ronan.lamy@gmail.com> | 2019-11-05 20:50:55 +0000 |
commit | 0cf2b560c13da5302cd5bb8b626d0a7305fe63b1 (patch) | |
tree | 15feb37094e2b03acd8e2eda13c42ee2498b59ae /pypy/tool | |
parent | Convert all remaining app_test_XXX functions to -D tests (diff) | |
download | pypy-0cf2b560c13da5302cd5bb8b626d0a7305fe63b1.tar.gz pypy-0cf2b560c13da5302cd5bb8b626d0a7305fe63b1.tar.bz2 pypy-0cf2b560c13da5302cd5bb8b626d0a7305fe63b1.zip |
Kill unused AppTestFunction
Diffstat (limited to 'pypy/tool')
-rw-r--r-- | pypy/tool/pytest/apptest.py | 20 | ||||
-rw-r--r-- | pypy/tool/pytest/pypy_test_failure_demo.py | 39 | ||||
-rw-r--r-- | pypy/tool/pytest/test/conftest1_innertest.py | 19 | ||||
-rw-r--r-- | pypy/tool/pytest/test/test_appsupport.py | 45 | ||||
-rw-r--r-- | pypy/tool/pytest/test/test_conftest1.py | 5 | ||||
-rw-r--r-- | pypy/tool/pytest/test/test_pytestsupport.py | 21 |
6 files changed, 21 insertions, 128 deletions
diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py index 8b97760f6c..2e4e8a8f36 100644 --- a/pypy/tool/pytest/apptest.py +++ b/pypy/tool/pytest/apptest.py @@ -1,7 +1,7 @@ # 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 diff --git a/pypy/tool/pytest/pypy_test_failure_demo.py b/pypy/tool/pytest/pypy_test_failure_demo.py index 8d6b4ecd4f..9844742045 100644 --- a/pypy/tool/pytest/pypy_test_failure_demo.py +++ b/pypy/tool/pytest/pypy_test_failure_demo.py @@ -1,39 +1,14 @@ -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) diff --git a/pypy/tool/pytest/test/conftest1_innertest.py b/pypy/tool/pytest/test/conftest1_innertest.py index 1cacbda32f..14c40e9a07 100644 --- a/pypy/tool/pytest/test/conftest1_innertest.py +++ b/pypy/tool/pytest/test/conftest1_innertest.py @@ -1,15 +1,12 @@ -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 + diff --git a/pypy/tool/pytest/test/test_appsupport.py b/pypy/tool/pytest/test/test_appsupport.py index dbd14541be..5c434e02f7 100644 --- a/pypy/tool/pytest/test/test_appsupport.py +++ b/pypy/tool/pytest/test/test_appsupport.py @@ -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) diff --git a/pypy/tool/pytest/test/test_conftest1.py b/pypy/tool/pytest/test/test_conftest1.py index 054ffa2029..5de55c94ec 100644 --- a/pypy/tool/pytest/test/test_conftest1.py +++ b/pypy/tool/pytest/test/test_conftest1.py @@ -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 diff --git a/pypy/tool/pytest/test/test_pytestsupport.py b/pypy/tool/pytest/test/test_pytestsupport.py index 53a5414785..9255054997 100644 --- a/pypy/tool/pytest/test/test_pytestsupport.py +++ b/pypy/tool/pytest/test/test_pytestsupport.py @@ -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") |