From 816d82c010e02d3d8deb74f64628e8aab5e1d6b1 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 19 Apr 2021 12:40:35 -0400 Subject: [PATCH] run_tests: fix pytest selection inside tox venv Finding the "right" pytest is challenging. In Debian, `pytest` is Python 2 while `pytest-3` is the Python 3 version ... but only when outside of a virtualenv. Inside of a virtualenv (e.g. the ones that tox creates), we always want `pytest`. Change-Id: Ic1fe84c10f06227bceeb9baad6a3c4598bbe9860 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/303802 Reviewed-by: Peter Kjellerstedt Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- run_tests | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/run_tests b/run_tests index 6c6f8594..573dd446 100755 --- a/run_tests +++ b/run_tests @@ -24,6 +24,10 @@ import sys def find_pytest(): """Try to locate a good version of pytest.""" + # If we're in a virtualenv, assume that it's provided the right pytest. + if 'VIRTUAL_ENV' in os.environ: + return 'pytest' + # Use the Python 3 version if available. ret = shutil.which('pytest-3') if ret: