Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

TST: Make deprecation warnings raise exceptions during test run

  • Loading branch information...
commit d93d0214eaec2cd45119ad1f7485e5628faffc2a 1 parent 27befc8
@mwiebe mwiebe authored
Showing with 19 additions and 9 deletions.
  1. +2 −5 README.txt
  2. +17 −4 numpy/testing/nosetester.py
View
7 README.txt
@@ -16,11 +16,8 @@ After installation, tests can be run with:
python -c 'import numpy; numpy.test()'
-When installing a new version of numpy for the first time or before upgrading
-to a newer version, it is recommended to turn on deprecation warnings when
-running the tests:
-
-python -Wd -c 'import numpy; numpy.test()'
+Starting in NumPy 1.7, deprecation warnings have been set to 'raise' by
+default, so the -Wd command-line option is no longer necessary.
The most current development version is always available from our
git repository:
View
21 numpy/testing/nosetester.py
@@ -6,6 +6,8 @@
"""
import os
import sys
+import warnings
+import numpy.testing.utils
def get_package_name(filepath):
"""
@@ -323,10 +325,21 @@ def test(self, label='fast', verbose=1, extra_argv=None, doctests=False,
import doctest
doctest.master = None
- argv, plugins = self.prepare_test_args(label, verbose, extra_argv,
- doctests, coverage)
- from noseclasses import NumpyTestProgram
- t = NumpyTestProgram(argv=argv, exit=False, plugins=plugins)
+ # Preserve the state of the warning filters
+ warn_ctx = numpy.testing.utils.WarningManager()
+ warn_ctx.__enter__()
+ try:
+
+ # Force deprecation warnings to raise
+ warnings.filterwarnings('error', category=DeprecationWarning)
+
+ argv, plugins = self.prepare_test_args(label, verbose, extra_argv,
+ doctests, coverage)
+ from noseclasses import NumpyTestProgram
+ t = NumpyTestProgram(argv=argv, exit=False, plugins=plugins)
+ finally:
+ warn_ctx.__exit__()
+
return t.result
def bench(self, label='fast', verbose=1, extra_argv=None):
Please sign in to comment.
Something went wrong with that request. Please try again.