summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Conrad <alexandre.conrad@gmail.com>2014-04-30 23:17:45 -0700
committerAlexandre Conrad <alexandre.conrad@gmail.com>2014-04-30 23:17:45 -0700
commitecd8e2fc9d278b099464e8b835e31146971eaa9b (patch)
tree6441be9a7686cf728c39e42178fffd79805a14f3
parent5547e3dcb952239093c2c4c47388759aaad60d80 (diff)
downloadtox-ecd8e2fc9d278b099464e8b835e31146971eaa9b.tar.gz
support skipping interpreters if any are missing
This implements the option --skip-missing-interpreters. If this option is passed to tox, the tests won't fail if interpreters are missing. The exit status will be 0 if all tests pass but interpreters were missing.
-rw-r--r--tests/test_z_cmdline.py16
-rw-r--r--tox/_cmdline.py12
-rw-r--r--tox/_config.py2
3 files changed, 29 insertions, 1 deletions
diff --git a/tests/test_z_cmdline.py b/tests/test_z_cmdline.py
index 537db5d..6d2575f 100644
--- a/tests/test_z_cmdline.py
+++ b/tests/test_z_cmdline.py
@@ -229,6 +229,22 @@ def test_unknown_interpreter(cmd, initproj):
"*ERROR*InterpreterNotFound*xyz_unknown_interpreter*",
])
+def test_skip_unknown_interpreter(cmd, initproj):
+ initproj("interp123-0.5", filedefs={
+ 'tests': {'test_hello.py': "def test_hello(): pass"},
+ 'tox.ini': '''
+ [testenv:python]
+ basepython=xyz_unknown_interpreter
+ [testenv]
+ changedir=tests
+ '''
+ })
+ result = cmd.run("tox", "--skip-missing-interpreters")
+ assert not result.ret
+ result.stdout.fnmatch_lines([
+ "*SKIPPED*InterpreterNotFound*xyz_unknown_interpreter*",
+ ])
+
def test_unknown_dep(cmd, initproj):
initproj("dep123-0.7", filedefs={
'tests': {'test_hello.py': "def test_hello(): pass"},
diff --git a/tox/_cmdline.py b/tox/_cmdline.py
index 192658d..5d58a18 100644
--- a/tox/_cmdline.py
+++ b/tox/_cmdline.py
@@ -222,6 +222,9 @@ class Reporter(object):
def error(self, msg):
self.logline("ERROR: " + msg, red=True)
+ def skip(self, msg):
+ self.logline("SKIPPED:" + msg, yellow=True)
+
def logline(self, msg, **opts):
self._reportedlines.append(msg)
self.tw.line("%s" % msg, **opts)
@@ -461,7 +464,14 @@ class Session:
retcode = 0
for venv in self.venvlist:
status = venv.status
- if status and status != "skipped tests":
+ if isinstance(status, tox.exception.InterpreterNotFound):
+ msg = " %s: %s" %(venv.envconfig.envname, str(status))
+ if self.config.option.skip_missing_interpreters:
+ self.report.skip(msg)
+ else:
+ retcode = 1
+ self.report.error(msg)
+ elif status and status != "skipped tests":
msg = " %s: %s" %(venv.envconfig.envname, str(status))
self.report.error(msg)
retcode = 1
diff --git a/tox/_config.py b/tox/_config.py
index 2753780..57df84d 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -129,6 +129,8 @@ def prepare_parse(pkgname):
"'pytest<2.7' or 'django>=1.6'.")
parser.add_argument("--sitepackages", action="store_true",
help="override sitepackages setting to True in all envs")
+ parser.add_argument("--skip-missing-interpreters", action="store_true",
+ help="don't fail tests for missing interpreters")
parser.add_argument("args", nargs="*",
help="additional arguments available to command positional substitution")