Skip to content

Commit 406355f

Browse files
authored
Merge pull request #1624 from blueyed/getexecutable-skip-non-zero-returncode
tests: getexecutable: call `--version` on all Pythons
2 parents 5d8d1db + e53e45b commit 406355f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

_pytest/pytester.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,18 @@ def getexecutable(name, cache={}):
123123
except KeyError:
124124
executable = py.path.local.sysfind(name)
125125
if executable:
126+
import subprocess
127+
popen = subprocess.Popen([str(executable), "--version"],
128+
universal_newlines=True, stderr=subprocess.PIPE)
129+
out, err = popen.communicate()
126130
if name == "jython":
127-
import subprocess
128-
popen = subprocess.Popen([str(executable), "--version"],
129-
universal_newlines=True, stderr=subprocess.PIPE)
130-
out, err = popen.communicate()
131131
if not err or "2.5" not in err:
132132
executable = None
133133
if "2.5.2" in err:
134134
executable = None # http://bugs.jython.org/issue1790
135+
elif popen.returncode != 0:
136+
# Handle pyenv's 127.
137+
executable = None
135138
cache[name] = executable
136139
return executable
137140

0 commit comments

Comments
 (0)