diff options
author | Mike Frysinger <vapier@google.com> | 2021-04-19 12:40:35 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-06-03 15:27:51 +0000 |
commit | 816d82c010e02d3d8deb74f64628e8aab5e1d6b1 (patch) | |
tree | e1bd68edf83509f4fe661beae9e05e4ecda9aa9c | |
parent | 2b37fa3f26e6667caf17e42237f16b5bfb58fdfd (diff) | |
download | git-repo-816d82c010e02d3d8deb74f64628e8aab5e1d6b1.tar.gz |
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 <peter.kjellerstedt@gmail.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
-rwxr-xr-x | run_tests | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -24,6 +24,10 @@ import sys | |||
24 | 24 | ||
25 | def find_pytest(): | 25 | def find_pytest(): |
26 | """Try to locate a good version of pytest.""" | 26 | """Try to locate a good version of pytest.""" |
27 | # If we're in a virtualenv, assume that it's provided the right pytest. | ||
28 | if 'VIRTUAL_ENV' in os.environ: | ||
29 | return 'pytest' | ||
30 | |||
27 | # Use the Python 3 version if available. | 31 | # Use the Python 3 version if available. |
28 | ret = shutil.which('pytest-3') | 32 | ret = shutil.which('pytest-3') |
29 | if ret: | 33 | if ret: |