diff options
-rw-r--r-- | numpy/__init__.py | 10 | ||||
-rw-r--r-- | numpy/core/__init__.py | 6 | ||||
-rw-r--r-- | numpy/distutils/__init__.py | 6 | ||||
-rw-r--r-- | numpy/f2py/__init__.py | 6 | ||||
-rw-r--r-- | numpy/fft/__init__.py | 6 | ||||
-rw-r--r-- | numpy/lib/__init__.py | 6 | ||||
-rw-r--r-- | numpy/linalg/__init__.py | 6 | ||||
-rw-r--r-- | numpy/ma/__init__.py | 6 | ||||
-rw-r--r-- | numpy/matrixlib/__init__.py | 6 | ||||
-rw-r--r-- | numpy/polynomial/__init__.py | 6 | ||||
-rw-r--r-- | numpy/random/__init__.py | 6 | ||||
-rw-r--r-- | numpy/testing/__init__.py | 2 | ||||
-rw-r--r-- | numpy/testing/nosetester.py | 17 |
13 files changed, 50 insertions, 39 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py index 5fda535f2..0fcd5097d 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -184,13 +184,11 @@ else: pkgload.__doc__ = PackageLoader.__call__.__doc__ + # We don't actually use this ourselves anymore, but I'm not 100% sure that + # no-one else in the world is using it (though I hope not) from .testing import Tester - if ".dev0" in __version__: - test = Tester(raise_warnings="develop").test - bench = Tester(raise_warnings="develop").bench - else: - test = Tester(raise_warnings="release").test - bench = Tester(raise_warnings="release").bench + test = testing.nosetester._numpy_tester().test + bench = testing.nosetester._numpy_tester().bench from . import core from .core import * diff --git a/numpy/core/__init__.py b/numpy/core/__init__.py index 16dcbe0b1..e8719ca75 100644 --- a/numpy/core/__init__.py +++ b/numpy/core/__init__.py @@ -55,9 +55,9 @@ __all__ += getlimits.__all__ __all__ += shape_base.__all__ -from numpy.testing import Tester -test = Tester().test -bench = Tester().bench +from numpy.testing.nosetester import _numpy_tester +test = _numpy_tester().test +bench = _numpy_tester().bench # Make it possible so that ufuncs can be pickled # Here are the loading and unloading functions diff --git a/numpy/distutils/__init__.py b/numpy/distutils/__init__.py index 9297185ef..766439d92 100644 --- a/numpy/distutils/__init__.py +++ b/numpy/distutils/__init__.py @@ -18,6 +18,6 @@ except ImportError: _INSTALLED = False if _INSTALLED: - from numpy.testing import Tester - test = Tester().test - bench = Tester().bench + from numpy.testing.nosetester import _numpy_tester + test = _numpy_tester().test + bench = _numpy_tester().bench diff --git a/numpy/f2py/__init__.py b/numpy/f2py/__init__.py index ef92114ed..50566ccc2 100644 --- a/numpy/f2py/__init__.py +++ b/numpy/f2py/__init__.py @@ -62,6 +62,6 @@ def compile(source, f.close() return status -from numpy.testing import Tester -test = Tester().test -bench = Tester().bench +from numpy.testing.nosetester import _numpy_tester +test = _numpy_tester().test +bench = _numpy_tester().bench diff --git a/numpy/fft/__init__.py b/numpy/fft/__init__.py index 96809a94f..a1f9e90e0 100644 --- a/numpy/fft/__init__.py +++ b/numpy/fft/__init__.py @@ -6,6 +6,6 @@ from .info import __doc__ from .fftpack import * from .helper import * -from numpy.testing import Tester -test = Tester().test -bench = Tester().bench +from numpy.testing.nosetester import _numpy_tester +test = _numpy_tester().test +bench = _numpy_tester().bench diff --git a/numpy/lib/__init__.py b/numpy/lib/__init__.py index 0606dfbbd..1d65db55e 100644 --- a/numpy/lib/__init__.py +++ b/numpy/lib/__init__.py @@ -41,6 +41,6 @@ __all__ += npyio.__all__ __all__ += financial.__all__ __all__ += nanfunctions.__all__ -from numpy.testing import Tester -test = Tester().test -bench = Tester().bench +from numpy.testing.nosetester import _numpy_tester +test = _numpy_tester().test +bench = _numpy_tester().bench diff --git a/numpy/linalg/__init__.py b/numpy/linalg/__init__.py index bc2a1ff6c..69445f541 100644 --- a/numpy/linalg/__init__.py +++ b/numpy/linalg/__init__.py @@ -50,6 +50,6 @@ from .info import __doc__ from .linalg import * -from numpy.testing import Tester -test = Tester().test -bench = Tester().test +from numpy.testing.nosetester import _numpy_tester +test = _numpy_tester().test +bench = _numpy_tester().bench diff --git a/numpy/ma/__init__.py b/numpy/ma/__init__.py index 05b641dff..af3468b01 100644 --- a/numpy/ma/__init__.py +++ b/numpy/ma/__init__.py @@ -51,6 +51,6 @@ __all__ = ['core', 'extras'] __all__ += core.__all__ __all__ += extras.__all__ -from numpy.testing import Tester -test = Tester().test -bench = Tester().bench +from numpy.testing.nosetester import _numpy_tester +test = _numpy_tester().test +bench = _numpy_tester().bench diff --git a/numpy/matrixlib/__init__.py b/numpy/matrixlib/__init__.py index d20696154..b2b76837a 100644 --- a/numpy/matrixlib/__init__.py +++ b/numpy/matrixlib/__init__.py @@ -7,6 +7,6 @@ from .defmatrix import * __all__ = defmatrix.__all__ -from numpy.testing import Tester -test = Tester().test -bench = Tester().bench +from numpy.testing.nosetester import _numpy_tester +test = _numpy_tester().test +bench = _numpy_tester().bench diff --git a/numpy/polynomial/__init__.py b/numpy/polynomial/__init__.py index 1200d1c8d..82c350e9b 100644 --- a/numpy/polynomial/__init__.py +++ b/numpy/polynomial/__init__.py @@ -22,6 +22,6 @@ from .hermite import Hermite from .hermite_e import HermiteE from .laguerre import Laguerre -from numpy.testing import Tester -test = Tester().test -bench = Tester().bench +from numpy.testing.nosetester import _numpy_tester +test = _numpy_tester().test +bench = _numpy_tester().bench diff --git a/numpy/random/__init__.py b/numpy/random/__init__.py index 388267c97..6c7d3140f 100644 --- a/numpy/random/__init__.py +++ b/numpy/random/__init__.py @@ -117,6 +117,6 @@ def __RandomState_ctor(): """ return RandomState(seed=0) -from numpy.testing import Tester -test = Tester().test -bench = Tester().bench +from numpy.testing.nosetester import _numpy_tester +test = _numpy_tester().test +bench = _numpy_tester().bench 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) |