Skip to content

Commit

Permalink
Merge pull request #7172 from gfyoung/backport-7116-and-7171
Browse files Browse the repository at this point in the history
TST: Backport #7116 and #7171
  • Loading branch information
charris committed Feb 2, 2016
2 parents 3a029a6 + 3aebcbb commit 409b267
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions numpy/tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,31 @@ def run_command(cmd, check_code=True):
def test_f2py():
# test that we can run f2py script
if sys.platform == 'win32':
f2py_cmd = r"%s\Scripts\f2py.py" % dirname(sys.executable)
exe_dir = dirname(sys.executable)

if exe_dir.endswith('Scripts'): # virtualenv
f2py_cmd = r"%s\f2py.py" % exe_dir
else:
f2py_cmd = r"%s\Scripts\f2py.py" % exe_dir

code, stdout, stderr = run_command([sys.executable, f2py_cmd, '-v'])
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:])
version = sys.version_info

# Python 2.6 'sys.version_info'
# is just a tuple, but this changes
# in Python 2.7 to have a more user-
# friendly interface with version[0]
# being the 'major' version and
# version[1] being the minor version
major = str(version[0])
minor = str(version[1])

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'])
Expand All @@ -79,5 +95,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)

0 comments on commit 409b267

Please sign in to comment.