summaryrefslogtreecommitdiffstats
path: root/run_tests
diff options
context:
space:
mode:
Diffstat (limited to 'run_tests')
-rwxr-xr-xrun_tests42
1 files changed, 2 insertions, 40 deletions
diff --git a/run_tests b/run_tests
index 5de51cf0..0ea098a6 100755
--- a/run_tests
+++ b/run_tests
@@ -15,46 +15,8 @@
15 15
16"""Wrapper to run pytest with the right settings.""" 16"""Wrapper to run pytest with the right settings."""
17 17
18import os
19import shutil
20import subprocess
21import sys 18import sys
22 19import pytest
23
24def find_pytest():
25 """Try to locate a good version of pytest."""
26 # If we're in a virtualenv, assume that it's provided the right pytest.
27 if 'VIRTUAL_ENV' in os.environ:
28 return 'pytest'
29
30 # Use the Python 3 version if available.
31 ret = shutil.which('pytest-3')
32 if ret:
33 return ret
34
35 # Hopefully this is a Python 3 version.
36 ret = shutil.which('pytest')
37 if ret:
38 return ret
39
40 print('%s: unable to find pytest.' % (__file__,), file=sys.stderr)
41 print('%s: Try installing: sudo apt-get install python-pytest' % (__file__,),
42 file=sys.stderr)
43
44
45def main(argv):
46 """The main entry."""
47 # Add the repo tree to PYTHONPATH as the tests expect to be able to import
48 # modules directly.
49 pythonpath = os.path.dirname(os.path.realpath(__file__))
50 oldpythonpath = os.environ.get('PYTHONPATH', None)
51 if oldpythonpath is not None:
52 pythonpath += os.pathsep + oldpythonpath
53 os.environ['PYTHONPATH'] = pythonpath
54
55 pytest = find_pytest()
56 return subprocess.run([pytest] + argv, check=False).returncode
57
58 20
59if __name__ == '__main__': 21if __name__ == '__main__':
60 sys.exit(main(sys.argv[1:])) 22 sys.exit(pytest.main(sys.argv[1:]))