Skip to content

Commit

Permalink
Discover python executable when discover is not used
Browse files Browse the repository at this point in the history
Currently it's hardcoded to 'python' wich in some cases may not exist,
as in some distros with python3 only.

This patch uses PYTHON env variable if defined or executable used to run
stestr.
  • Loading branch information
amoralej committed May 14, 2019
1 parent 58fdc8c commit 2dc62b3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion stestr/commands/run.py
Expand Up @@ -348,7 +348,15 @@ def run_command(config='.stestr.conf', repo_type='file',
if ids.find('/') != -1:
root = ids.replace('.py', '')
ids = root.replace('/', '.')
run_cmd = 'python -m subunit.run ' + ids
stestr_python = sys.executable
if os.environ.get('PYTHON'):
python_bin = os.environ.get('PYTHON')
elif stestr_python:
python_bin = stestr_python
else:
raise RuntimeError("The Python interpreter was not found and "
"PYTHON is not set")
run_cmd = python_bin + ' -m subunit.run ' + ids

def run_tests():
run_proc = [('subunit', output.ReturnCodeToSubunit(
Expand Down

0 comments on commit 2dc62b3

Please sign in to comment.