summaryrefslogtreecommitdiff
path: root/numpy/testing
diff options
context:
space:
mode:
authorNathaniel J. Smith <njs@pobox.com>2015-12-30 03:01:03 -0800
committerNathaniel J. Smith <njs@pobox.com>2015-12-30 05:43:43 -0800
commita61ddd3812cc95f9c9e6eeac7f8bcfb92130f978 (patch)
treeeda1bbe23db037bf224179400eaade20266afe22 /numpy/testing
parent237ab4398ac880be30fc262e7bf6163e9baff921 (diff)
downloadnumpy-a61ddd3812cc95f9c9e6eeac7f8bcfb92130f978.tar.gz
[TST] Refactor new raise_warnings logic for subpackage test suites
Diffstat (limited to 'numpy/testing')
-rw-r--r--numpy/testing/__init__.py2
-rw-r--r--numpy/testing/nosetester.py17
2 files changed, 16 insertions, 3 deletions
diff --git a/numpy/testing/__init__.py b/numpy/testing/__init__.py
index dcc02ad57..625fdecdc 100644
--- a/numpy/testing/__init__.py
+++ b/numpy/testing/__init__.py
@@ -12,4 +12,4 @@ from unittest import TestCase
from . import decorators as dec
from .nosetester import run_module_suite, NoseTester as Tester
from .utils import *
-test = Tester().test
+test = nosetester._numpy_tester().test
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)