diff options
| author | Adam Hupp <adam@hupp.org> | 2020-05-05 13:34:16 -0700 |
|---|---|---|
| committer | Adam Hupp <adam@hupp.org> | 2020-05-05 13:43:31 -0700 |
| commit | cd8fb9d25246d8bf90290356186056c631834b7a (patch) | |
| tree | e6535061eb43ebf4ae42e4020ca9a32ac8d11ee3 /test/run.py | |
| parent | 8ed5dc4759e7e7eb879494f246d3c5eec7580376 (diff) | |
| download | python-magic-cd8fb9d25246d8bf90290356186056c631834b7a.tar.gz | |
Improve test coverage
Make sure we fail early if any versions fail, and move to a python
test runner since I can never remember how to use bash.
Diffstat (limited to 'test/run.py')
| -rw-r--r-- | test/run.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/run.py b/test/run.py new file mode 100644 index 0000000..c10c11f --- /dev/null +++ b/test/run.py @@ -0,0 +1,32 @@ + +import subprocess +import os.path +import sys + +this_dir = os.path.dirname(sys.argv[0]) + +new_env = { + 'LC_ALL': 'en_US.UTF-8', + 'PYTHONPATH': os.path.join(this_dir, ".."), +} + +def has_py(version): + ret = subprocess.run("which %s" % version, shell=True, stdout=subprocess.DEVNULL) + return ret.returncode == 0 + +def run_test(versions): + + found = False + for i in versions: + if not has_py(i): + # if this version doesn't exist in path, skip + continue + found = True + print("Testing %s" % i) + subprocess.run([i, os.path.join(this_dir, "test.py")], env=new_env, check=True) + + if not found: + sys.exit("No versions found: " + str(versions)) + +run_test(["python2", "python2.7"]) +run_test(["python3.5", "python3.6", "python3.7", "python3.8"]) |
