summaryrefslogtreecommitdiff
path: root/tools/test-installed-numpy.py
diff options
context:
space:
mode:
authorNathaniel J. Smith <njs@pobox.com>2012-05-21 23:33:19 +0100
committerNathaniel J. Smith <njs@pobox.com>2012-05-21 23:33:19 +0100
commite3e5028e2e5c1e55b63dac6624df1c6713a6d274 (patch)
treeed156d1138d6a52c402f46d27ee0b8afea30ce30 /tools/test-installed-numpy.py
parent3f45eaa310b0ead7270d56697018173dc4b7daad (diff)
downloadpython-numpy-e3e5028e2e5c1e55b63dac6624df1c6713a6d274.tar.gz
python-numpy-e3e5028e2e5c1e55b63dac6624df1c6713a6d274.tar.bz2
python-numpy-e3e5028e2e5c1e55b63dac6624df1c6713a6d274.zip
Add a little command-line tool for running tests, plus tox support
Tox is a handy little tool to make it easier than not to run proper tests that exercise the build system and are run against multiple Python versions: http://pypi.python.org/pypi/tox See comment at the top of tox.ini for hints.
Diffstat (limited to 'tools/test-installed-numpy.py')
-rw-r--r--tools/test-installed-numpy.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tools/test-installed-numpy.py b/tools/test-installed-numpy.py
new file mode 100644
index 000000000..91e619e96
--- /dev/null
+++ b/tools/test-installed-numpy.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+
+# A simple script to test the installed version of numpy by calling
+# 'numpy.test()'. Key features:
+# -- convenient command-line syntax
+# -- sets exit status appropriately, useful for automated test environments
+
+# It would be better to set this up as a module in the numpy namespace, so
+# that it could be run as:
+# python -m numpy.run_tests <args>
+# But, python2.4's -m switch only works with top-level modules, not modules
+# that are inside packages. So, once we drop 2.4 support, maybe...
+
+import sys
+# In case we are run from the source directory, we don't want to import numpy
+# from there, we want to import the installed version:
+sys.path.pop(0)
+
+from optparse import OptionParser
+parser = OptionParser("usage: %prog [options] -- [nosetests options]")
+parser.add_option("-v", "--verbose",
+ action="count", dest="verbose", default=1,
+ help="increase verbosity")
+parser.add_option("--doctests",
+ action="store_true", dest="doctests", default=False,
+ help="Run doctests in module")
+parser.add_option("--coverage",
+ action="store_true", dest="coverage", default=False,
+ help="report coverage of NumPy code (requires 'coverage' module")
+parser.add_option("-m", "--mode",
+ action="store", dest="mode", default="fast",
+ help="'fast', 'full', or something that could be "
+ "passed to nosetests -A [default: %default]")
+(options, args) = parser.parse_args()
+
+import numpy
+result = numpy.test(options.mode,
+ verbose=options.verbose,
+ extra_argv=args,
+ doctests=options.doctests,
+ coverage=options.coverage)
+
+if result.wasSuccessful():
+ sys.exit(0)
+else:
+ sys.exit(1)