diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2012-02-25 10:17:02 -0800 |
---|---|---|
committer | Mark Wiebe <mwwiebe@gmail.com> | 2012-03-04 12:58:41 -0800 |
commit | eec299b2a384b92a45e6965dadce23b7a40ab250 (patch) | |
tree | 188cc7f651b0de064e59afb53968bf6b24ba6b02 /numpy/testing/nosetester.py | |
parent | 1857ee3e9049260366634f350d67c3fe7609116c (diff) | |
download | numpy-eec299b2a384b92a45e6965dadce23b7a40ab250.tar.gz |
TST,WRN: Add a parameter to control which warnings raise during testing
The default is set to (RuntimeWarning, DeprecationWarning), and
the intent is to leave it as this on master, but change it to ()
immediately after branching for 1.7 in that branch.
Diffstat (limited to 'numpy/testing/nosetester.py')
-rw-r--r-- | numpy/testing/nosetester.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index 074ac1766..682a6be23 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -252,8 +252,9 @@ class NoseTester(object): argv += ['--with-' + plug.name] return argv, plugins - def test(self, label='fast', verbose=1, extra_argv=None, doctests=False, - coverage=False): + def test(self, label='fast', verbose=1, extra_argv=None, + doctests=False, coverage=False, + raisewarnings=(DeprecationWarning, RuntimeWarning)): """ Run tests for module using nose. @@ -279,6 +280,11 @@ 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>`_). + raisewarnings : tuple 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. The default is (DeprecationWarning, + RuntimeWarning). Returns ------- @@ -329,11 +335,12 @@ class NoseTester(object): warn_ctx = numpy.testing.utils.WarningManager() warn_ctx.__enter__() try: - - # Force deprecation warnings to raise - warnings.filterwarnings('error', category=DeprecationWarning) - # Force runtime warnings to raise - warnings.filterwarnings('error', category=RuntimeWarning) + # Reset the warning filters to the default state, + # so that running the tests is more repeatable. + warnings.resetwarnings() + # Force the requested warnings to raise + for warningtype in raisewarnings: + warnings.filterwarnings('error', category=warningtype) argv, plugins = self.prepare_test_args(label, verbose, extra_argv, doctests, coverage) |