From a05aedac367435f7ee1e15149d7764bcbcc37c69 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 28 Feb 2017 18:03:53 -0600 Subject: Include the venv path in PATH If a test shells out to a thing installed in the venv, it needs venv/bin in the path so it can find it. --- ttrun/cmd.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ttrun/cmd.py b/ttrun/cmd.py index a237b1b..b392277 100644 --- a/ttrun/cmd.py +++ b/ttrun/cmd.py @@ -16,6 +16,7 @@ # along with Ansible. If not, see . import argparse +import os import subprocess import sys @@ -35,11 +36,14 @@ def main(): args = parse_arguments() if args.environment: - return subprocess.call([ - '.tox/{environment}/bin/python'.format( - environment=args.environment), - '-m', - 'testtools.run'] + args.tests) + envpath = '.tox/{environment}/bin'.format(environment=args.environment) + pyexe = '{envpath}/python'.format(envpath=envpath) + # Executables in the virtualenv need to be in the path + os.environ['PATH'] = '{envpath}:{path}'.format( + envpath=envpath, path=os.environ['PATH']) + return subprocess.Popen( + [pyexe, '-m', 'testtools.run'] + args.tests, + env=os.environ).wait() else: return testtools.run.main([sys.argv[0]] + args.tests, sys.stdout) -- cgit v1.2.3