From ffe8887cc6ab2d45bf366b2b039f73e7aa8a5d5f Mon Sep 17 00:00:00 2001 From: wiredfool Date: Wed, 23 Jul 2014 08:48:55 -0700 Subject: [PATCH] profiler for testing --- profile-installed.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 profile-installed.py diff --git a/profile-installed.py b/profile-installed.py new file mode 100755 index 000000000..485792f51 --- /dev/null +++ b/profile-installed.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +import nose +import os +import sys +import glob + +import profile + +# monkey with the path, removing the local directory but adding the Tests/ +# directory for helper.py and the other local imports there. + +del(sys.path[0]) +sys.path.insert(0, os.path.abspath('./Tests')) + +# if there's no test selected (mostly) choose a working default. +# Something is required, because if we import the tests from the local +# directory, once again, we've got the non-installed PIL in the way +if len(sys.argv) == 1: + sys.argv.extend(glob.glob('Tests/test*.py')) + +# Make sure that nose doesn't muck with our paths. +if ('--no-path-adjustment' not in sys.argv) and ('-P' not in sys.argv): + sys.argv.insert(1, '--no-path-adjustment') + +if 'NOSE_PROCESSES' not in os.environ: + for arg in sys.argv: + if '--processes' in arg: + break + else: # for + sys.argv.insert(1, '--processes=-1') # -1 == number of cores + sys.argv.insert(1, '--process-timeout=30') + +if __name__ == '__main__': + profile.run("nose.main()", sort=2)