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.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py
index e65416224..6cf7defab 100644
--- a/numpy/testing/nosetester.py
+++ b/numpy/testing/nosetester.py
@@ -159,6 +159,12 @@ class NoseTester(object):
- "release" : equals ``()``, don't raise on any warnings.
Default is "release".
+ depth : int, optional
+ If `package` is None, then this can be used to initialize from the
+ module of the caller of (the caller of (...)) the code that
+ initializes `NoseTester`. Default of 0 means the module of the
+ immediate caller; higher values are useful for utility routines that
+ want to initialize `NoseTester` objects on behalf of other code.
"""
# Stuff to exclude from tests. These are from numpy.distutils
@@ -168,7 +174,7 @@ class NoseTester(object):
'pyrex_ext',
'swig_ext']
- def __init__(self, package=None, raise_warnings="release"):
+ def __init__(self, package=None, raise_warnings="release", depth=0):
# Back-compat: 'None' used to mean either "release" or "develop"
# depending on whether this was a release or develop version of
# numpy. Those semantics were fine for testing numpy, but not so
@@ -182,7 +188,7 @@ class NoseTester(object):
package_name = None
if package is None:
- f = sys._getframe(1)
+ f = sys._getframe(1 + depth)
package_path = f.f_locals.get('__file__', None)
if package_path is None:
raise AssertionError
@@ -511,3 +517,10 @@ class NoseTester(object):
add_plugins = [Unplugger('doctest')]
return nose.run(argv=argv, addplugins=add_plugins)
+
+def _numpy_tester():
+ if hasattr(np, "__version__") and ".dev0" in np.__version__:
+ mode = "develop"
+ else:
+ mode = "release"
+ return NoseTester(raise_warnings=mode, depth=1)