summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-01-26 08:20:40 -0700
committerCharles Harris <charlesr.harris@gmail.com>2016-01-26 08:20:40 -0700
commitcc2b0495118e4855acfeaea3253abf449f3e91dd (patch)
tree636aef59cda23c37024666ca63f155245f7123b2
parent471bab33bbfac24df42221b5c5739a190ca4018e (diff)
parent588a1c3e42302418de80eb5f7da4ad375228396e (diff)
downloadnumpy-cc2b0495118e4855acfeaea3253abf449f3e91dd.tar.gz
Merge pull request #7118 from gfyoung/f2py_patch_linux
TST: Fixed f2py test for non-versioned python executables
-rw-r--r--numpy/tests/test_scripts.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/numpy/tests/test_scripts.py b/numpy/tests/test_scripts.py
index 2aed75eba..0fc7f879f 100644
--- a/numpy/tests/test_scripts.py
+++ b/numpy/tests/test_scripts.py
@@ -16,6 +16,7 @@ from numpy.testing import assert_
is_inplace = isfile(pathjoin(dirname(np.__file__), '..', 'setup.py'))
+
def run_command(cmd, check_code=True):
""" Run command sequence `cmd` returning exit code, stdout, stderr
@@ -73,10 +74,18 @@ def test_f2py():
success = stdout.strip() == asbytes('2')
assert_(success, "Warning: f2py not found in path")
else:
- # unclear what f2py cmd was installed as, check plain (f2py) and
- # current python version specific one (f2py3.4)
- f2py_cmds = ('f2py', 'f2py' + basename(sys.executable)[6:])
+ # unclear what f2py cmd was installed as, check plain (f2py),
+ # with major version (f2py3), or major/minor version (f2py3.4)
+ code, stdout, stderr = run_command([sys.executable, '-V'])
+
+ # for some reason, 'python -V' returns version in 'stderr' for
+ # Python 2.x but in 'stdout' for Python 3.x
+ version = (stdout or stderr)[7:].strip()
+ major, minor, revision = version.decode('utf-8').split('.')
+
+ f2py_cmds = ('f2py', 'f2py' + major, 'f2py' + major + '.' + minor)
success = False
+
for f2py_cmd in f2py_cmds:
try:
code, stdout, stderr = run_command([f2py_cmd, '-v'])
@@ -85,5 +94,5 @@ def test_f2py():
break
except:
pass
- msg = "Warning: neither %s nor %s found in path" % f2py_cmds
+ msg = "Warning: neither %s nor %s nor %s found in path" % f2py_cmds
assert_(success, msg)