summaryrefslogtreecommitdiff
path: root/numpy/testing/nosetester.py
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@googlemail.com>2012-03-04 20:40:31 +0100
committerMark Wiebe <mwwiebe@gmail.com>2012-03-04 12:59:35 -0800
commit8df4e67caedd2aa42c932c605ad833c9702452a0 (patch)
treea20bdbf6f92badbb72b5d433e5b7eca8905d11d1 /numpy/testing/nosetester.py
parent7961e1f56ec9754cafcb9a67445b01d47d1b1676 (diff)
downloadnumpy-8df4e67caedd2aa42c932c605ad833c9702452a0.tar.gz
TST: add some string kw options to simplify switching NoseTester behavior.
Diffstat (limited to 'numpy/testing/nosetester.py')
-rw-r--r--numpy/testing/nosetester.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py
index 9041ff69d..7dfc9cf03 100644
--- a/numpy/testing/nosetester.py
+++ b/numpy/testing/nosetester.py
@@ -108,18 +108,22 @@ class NoseTester(object):
The package to test. If a string, this should be the full path to
the package. If None (default), `package` is set to the module from
which `NoseTester` is initialized.
- raise_warnings : sequence of warnings, optional
+ raise_warnings : str or sequence of warnings, optional
This specifies which warnings to configure as 'raise' instead
- of 'warn' during the test execution. To disable this feature,
- pass an empty tuple. See Notes for more details.
+ of 'warn' during the test execution. Valid strings are:
+
+ - "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 the master branch 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.
+ for the master branch of NumPy, and ``()`` for maintenance branches and
+ 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.
"""
# Stuff to exclude from tests. These are from numpy.distutils
@@ -129,8 +133,7 @@ class NoseTester(object):
'pyrex_ext',
'swig_ext']
- def __init__(self, package=None,
- raise_warnings=(DeprecationWarning, RuntimeWarning)):
+ def __init__(self, package=None, raise_warnings="develop"):
package_name = None
if package is None:
f = sys._getframe(1)
@@ -287,13 +290,12 @@ class NoseTester(object):
If True, report coverage of NumPy code. Default is False.
(This requires the `coverage module:
<http://nedbatchelder.com/code/modules/coverage.html>`_).
- raise_warnings : sequence of warnings, optional
+ raise_warnings : str or sequence of warnings, optional
This specifies which warnings to configure as 'raise' instead
- of 'warn' during the test execution. To disable this feature,
- pass an empty sequence.
- The default (None) is determined by the `NoseTester` constructor.
- For NumPy it is set to ``(DeprecationWarning, RuntimeWarning)``
- during development, and to ``()`` for released versions.
+ of 'warn' during the test execution. Valid strings are:
+
+ - "develop" : equals ``(DeprecationWarning, RuntimeWarning)``
+ - "release" : equals ``()``, don't raise on any warnings.
Returns
-------
@@ -343,6 +345,11 @@ class NoseTester(object):
if raise_warnings is None:
raise_warnings = self.raise_warnings
+ _warn_opts = dict(develop=(DeprecationWarning, RuntimeWarning),
+ release=())
+ if raise_warnings in _warn_opts.keys():
+ raise_warnings = _warn_opts[raise_warnings]
+
# Preserve the state of the warning filters
warn_ctx = numpy.testing.utils.WarningManager()
warn_ctx.__enter__()