[pypy-commit] pypy py3k: kill the --appdirect option and leave only --runappdirect, which by default tries to run the tests with the python3 executable found in the path, unless you specify another one with --python
antocuni
noreply at buildbot.pypy.org
Fri Jan 27 20:29:23 CET 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r51878:f3e4991575d5
Date: 2012-01-27 15:25 +0100
http://bitbucket.org/pypy/pypy/changeset/f3e4991575d5/
Log: kill the --appdirect option and leave only --runappdirect, which by
default tries to run the tests with the python3 executable found in
the path, unless you specify another one with --python
diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -10,6 +10,10 @@
from pypy.tool.autopath import pypydir
from pypy.tool import leakfinder, runsubprocess
+PYTHON3 = py.path.local.sysfind('python3')
+if PYTHON3 is not None:
+ PYTHON3 = str(PYTHON3)
+
# pytest settings
rsyncdirs = ['.', '../lib-python', '../lib_pypy', '../demo']
rsyncignore = ['_cache']
@@ -25,8 +29,6 @@
def pytest_configure(config):
global option
option = config.option
- if option.appdirect:
- option.runappdirect = True
def _set_platform(opt, opt_str, value, parser):
from pypy.config.translationoption import PLATFORMS
@@ -41,9 +43,10 @@
help="view translation tests' flow graphs with Pygame")
group.addoption('-A', '--runappdirect', action="store_true",
default=False, dest="runappdirect",
- help="run applevel tests directly on python interpreter (not through PyPy)")
- group.addoption('--appdirect', type="string",
- help="run applevel tests directly with the specified interpreter")
+ help="run applevel tests directly on the python interpreter " +
+ "specified by --python")
+ group.addoption('--python', type="string", default=PYTHON3,
+ help="python interpreter to run appdirect tests with")
group.addoption('--direct', action="store_true",
default=False, dest="rundirect",
help="run pexpect tests directly")
@@ -195,6 +198,8 @@
py.test.skip("translation test, skipped for appdirect")
def run_with_python(python, target):
+ if python is None:
+ py.test.skip("Cannot find the default python3 interpreter to run with -A")
helpers = """if 1:
def skip(message):
print(message)
@@ -424,7 +429,7 @@
target = self.obj
src = extract_docstring_if_empty_function(target)
if self.config.option.runappdirect:
- return run_appdirect_or_skip(self.config, target, src)
+ return run_with_python(self.config.option.python, src)
space = gettestobjspace()
filename = self._getdynfilename(target)
func = app2interp_temp(src, filename=filename)
@@ -468,24 +473,13 @@
target = self.obj
src = extract_docstring_if_empty_function(target.im_func)
if self.config.option.runappdirect:
- return run_appdirect_or_skip(self.config, target, src)
+ return run_with_python(self.config.option.python, src)
space = target.im_self.space
filename = self._getdynfilename(target)
func = app2interp_temp(src, filename=filename)
w_instance = self.parent.w_instance
self.execute_appex(space, func, space, w_instance)
-def run_appdirect_or_skip(config, target, src):
- if config.option.appdirect:
- return run_with_python(config.option.appdirect, src)
- if isinstance(src, str):
- # we are trying to directly run a test whose code is inside
- # the docstring. This cannot work because the code might
- # contain py3k-only syntax, while we are on a python2 hosting
- # python. So, we just skip the test
- py.test.skip('Cannot run docstring-tests with -A')
- return target()
-
def extract_docstring_if_empty_function(fn):
def empty_func():
diff --git a/pypy/tool/pytest/test/test_conftest1.py b/pypy/tool/pytest/test/test_conftest1.py
--- a/pypy/tool/pytest/test/test_conftest1.py
+++ b/pypy/tool/pytest/test/test_conftest1.py
@@ -32,15 +32,6 @@
assert "app_test_something" in passed[0].nodeid
assert "test_method_app" in passed[1].nodeid
- def test_appdirect(self, testdir):
- sorter = testdir.inline_run(innertest, '-k', 'applevel -docstring',
- '--appdirect=%s' % (sys.executable,))
- passed, skipped, failed = sorter.listoutcomes()
- assert len(passed) == 2
- print passed
- assert "app_test_something" in passed[0].nodeid
- assert "test_method_app" in passed[1].nodeid
-
def test_docstring_in_methods(self, testdir):
sorter = testdir.inline_run("-k", "AppTestSomething test_code_in_docstring",
innertest)
@@ -65,17 +56,6 @@
'--runappdirect')
passed, skipped, failed = sorter.listoutcomes()
assert len(passed) == 1
- assert len(skipped) == 2
- assert "test_code_in_docstring_ignored" in passed[0].nodeid
- assert "app_test_code_in_docstring_failing" in skipped[0].nodeid
- assert "test_code_in_docstring_failing" in skipped[1].nodeid
-
- def test_docstring_appdirect(self, testdir):
- sorter = testdir.inline_run(innertest,
- '-k', 'test_code_in_docstring',
- '--appdirect=%s' % (sys.executable,))
- passed, skipped, failed = sorter.listoutcomes()
- assert len(passed) == 1
assert len(failed) == 2
assert "test_code_in_docstring_ignored" in passed[0].nodeid
assert "app_test_code_in_docstring_failing" in failed[0].nodeid
More information about the pypy-commit
mailing list