From e53e45b55c71f92967af9c55c800d7818b5ac073 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 21 Jun 2016 08:36:02 +0200 Subject: [PATCH] tests: getexecutable: call `--version` on all Pythons This should prevent errors from pyenv: pyenv: python2.6: command not found The `python2.6' command exists in these Python versions: 2.6.9 While the pyenv wrapper explicitly returns 127, I think it is better to just check for non-zero?! --- _pytest/pytester.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/_pytest/pytester.py b/_pytest/pytester.py index faed7f581..697f5218f 100644 --- a/_pytest/pytester.py +++ b/_pytest/pytester.py @@ -123,15 +123,18 @@ def getexecutable(name, cache={}): except KeyError: executable = py.path.local.sysfind(name) if executable: + import subprocess + popen = subprocess.Popen([str(executable), "--version"], + universal_newlines=True, stderr=subprocess.PIPE) + out, err = popen.communicate() if name == "jython": - import subprocess - popen = subprocess.Popen([str(executable), "--version"], - universal_newlines=True, stderr=subprocess.PIPE) - out, err = popen.communicate() if not err or "2.5" not in err: executable = None if "2.5.2" in err: executable = None # http://bugs.jython.org/issue1790 + elif popen.returncode != 0: + # Handle pyenv's 127. + executable = None cache[name] = executable return executable