summaryrefslogtreecommitdiff
path: root/numpy/testing/nosetester.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/testing/nosetester.py')
-rw-r--r--numpy/testing/nosetester.py49
1 files changed, 47 insertions, 2 deletions
diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py
index 77ac61074..a06d559e7 100644
--- a/numpy/testing/nosetester.py
+++ b/numpy/testing/nosetester.py
@@ -75,14 +75,55 @@ def import_nose():
return nose
-def run_module_suite(file_to_run = None):
+def run_module_suite(file_to_run=None, argv=None):
+ """
+ Run a test module.
+
+ Equivalent to calling ``$ nosetests <argv> <file_to_run>`` from
+ the command line
+
+ Parameters
+ ----------
+ file_to_run: str, optional
+ Path to test module, or None.
+ By default, run the module from which this function is called.
+ argv: list of strings
+ Arguments to be passed to the nose test runner. ``argv[0]`` is
+ ignored. All command line arguments accepted by ``nosetests``
+ will work.
+
+ .. versionadded:: 1.9.0
+
+ Examples
+ --------
+ Adding the following::
+
+ if __name__ == "__main__" :
+ run_module_suite(argv=sys.argv)
+
+ at the end of a test module will run the tests when that module is
+ called in the python interpreter.
+
+ Alternatively, calling::
+
+ >>> run_module_suite(file_to_run="numpy/tests/test_matlib.py")
+
+ from an interpreter will run all the test routine in 'test_matlib.py'.
+ """
if file_to_run is None:
f = sys._getframe(1)
file_to_run = f.f_locals.get('__file__', None)
if file_to_run is None:
raise AssertionError
- import_nose().run(argv=['', file_to_run])
+ if argv is None:
+ argv = ['', file_to_run]
+ else:
+ argv = argv + [file_to_run]
+
+ nose = import_nose()
+ from .noseclasses import KnownFailure
+ nose.run(argv=argv, addplugins=[KnownFailure()])
class NoseTester(object):
@@ -378,6 +419,10 @@ class NoseTester(object):
warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
warnings.filterwarnings("ignore", category=ModuleDeprecationWarning)
warnings.filterwarnings("ignore", category=FutureWarning)
+ # Filter out boolean '-' deprecation messages. This allows
+ # older versions of scipy to test without a flood of messages.
+ warnings.filterwarnings("ignore", message=".*boolean negative.*")
+ warnings.filterwarnings("ignore", message=".*boolean subtract.*")
from .noseclasses import NumpyTestProgram