summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel J. Smith <njs@pobox.com>2015-12-29 17:52:41 -0800
committerNathaniel J. Smith <njs@pobox.com>2015-12-29 18:25:56 -0800
commit237ab4398ac880be30fc262e7bf6163e9baff921 (patch)
tree0f70a7e2f771b8677d76e73553b049eeec827285
parent004639d07fd161d1394f5dda1b6ed42c777f3c80 (diff)
downloadnumpy-237ab4398ac880be30fc262e7bf6163e9baff921.tar.gz
[FIX] fix NoseTester's raise_warning default
Our test-runner's raise_warning mode traditionally has varied depending on whether we have a development or release version of numpy: for development versions we raise on warnings, and for release versions we don't. This is all very sensible... *if* you're running numpy's test suite. But our test-runner is also used by other packages like scipy, and it doesn't make sense for scipy's raise_warning mode to vary depending on whether *numpy* is a development or release version. (It should vary depending on whether the scipy-under-test is a development or release version.) So this commit moves the numpy-version-dependent raise_warning logic out of the generic NoseTester class and into numpy-specific code. (See scipy/scipy#5609 for more discussion.)
-rw-r--r--numpy/__init__.py8
-rw-r--r--numpy/testing/nosetester.py25
2 files changed, 17 insertions, 16 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py
index d4ef54d83..5fda535f2 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -185,8 +185,12 @@ else:
pkgload.__doc__ = PackageLoader.__call__.__doc__
from .testing import Tester
- test = Tester().test
- bench = Tester().bench
+ 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
from . import core
from .core import *
diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py
index 551e630ec..e65416224 100644
--- a/numpy/testing/nosetester.py
+++ b/numpy/testing/nosetester.py
@@ -158,15 +158,7 @@ class NoseTester(object):
- "develop" : equals ``(DeprecationWarning, RuntimeWarning)``
- "release" : equals ``()``, don't raise on any warnings.
- See Notes for more details.
-
- Notes
- -----
- The default for `raise_warnings` is
- ``(DeprecationWarning, RuntimeWarning)`` for development versions of NumPy,
- and ``()`` for released versions. The purpose of this switching behavior
- is to catch as many warnings as possible during development, but not give
- problems for packaging of released versions.
+ Default is "release".
"""
# Stuff to exclude from tests. These are from numpy.distutils
@@ -176,11 +168,16 @@ class NoseTester(object):
'pyrex_ext',
'swig_ext']
- def __init__(self, package=None, raise_warnings=None):
- if raise_warnings is None and (
- not hasattr(np, '__version__') or '.dev0' in np.__version__):
- raise_warnings = "develop"
- elif raise_warnings is None:
+ def __init__(self, package=None, raise_warnings="release"):
+ # 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
+ # helpful for downstream projects like scipy that use
+ # numpy.testing. (They want to set this based on whether *they* are a
+ # release or develop version, not whether numpy is.) So we continue to
+ # accept 'None' for back-compat, but it's now just an alias for the
+ # default "release".
+ if raise_warnings is None:
raise_warnings = "release"
package_name = None