X-Git-Url: https://git.phdru.name/?p=cookiecutter.git;a=blobdiff_plain;f=project_template%2Ftests%2Frun_all.py;fp=project_template%2Ftests%2Frun_all.py;h=2e217bf31e814c42286fc7a96912fd53e6c3680b;hp=0000000000000000000000000000000000000000;hb=d15f85bc0e619e222f849804eec6c30e7c762c90;hpb=f3a77fb183a5d87ad6118547ec76632af59d36a7 diff --git a/project_template/tests/run_all.py b/project_template/tests/run_all.py new file mode 100755 index 0000000..2e217bf --- /dev/null +++ b/project_template/tests/run_all.py @@ -0,0 +1,38 @@ +#! /usr/bin/env python + + +import os +import sys +import subprocess + + +def isexecutable(filename): + infile = open(filename, 'r') + magic = infile.read(2) + infile.close() + return magic == "#!" + + +def collect_tests(): + tests = [] + for dirpath, dirs, files in os.walk("tests"): + tests.extend( + [os.path.join(dirpath, filename) for filename in files + if filename.startswith("test") and filename.endswith(".py") + ]) + return [test[:-3].replace(os.sep, '.') for test in tests + if isexecutable(test)] + + +def main(): + os.chdir(os.path.join(os.path.dirname(sys.argv[0]), os.pardir)) + tests = collect_tests() + + os.environ["PYTHONPATH"] = os.curdir + + for test in sorted(tests): + print test + subprocess.call((sys.executable, '-m', test)) + +if __name__ == '__main__': + main()