8000 TST: Make deprecation warnings raise exceptions during test run · numpy-buildbot/numpy@d93d021 · GitHub
[go: up one dir, main page]

Skip to content

Commit d93d021

Browse files
committed
TST: Make deprecation warnings raise exceptions during test run
1 parent 27befc8 commit d93d021

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

README.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ After installation, tests can be run with:
1616

1717
python -c 'import numpy; numpy.test()'
1818

19-
When installing a new version of numpy for the first time or before upgrading
20-
to a newer version, it is recommended to turn on deprecation warnings when
21-
running the tests:
22-
23-
python -Wd -c 'import numpy; numpy.test()'
19+
Starting in NumPy 1.7, deprecation warnings have been set to 'raise' by
20+
default, so the -Wd command-line option is no longer necessary.
2421

2522
The most current development version is always available from our
2623
git repository:

numpy/testing/nosetester.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"""
77
import os
88
import sys
9+
import warnings
10+
import numpy.testing.utils
911

1012
def get_package_name(filepath):
1113
"""
@@ -323,10 +325,21 @@ def test(self, label='fast', verbose=1, extra_argv=None, doctests=False,
323325
import doctest
324326
doctest.master = None
325327

326-
argv, plugins = self.prepare_test_args(label, verbose, extra_argv,
327-
doctests, coverage)
328-
from noseclasses import NumpyTestProgram
329-
t = NumpyTestProgram(argv=argv, exit=False, plugins=plugins)
328+
# Preserve the state of the warning filters
329+
warn_ctx = numpy.testing.utils.WarningManager()
330+
warn_ctx.__enter__()
331+
try:
332+
333+
# Force deprecation warnings to raise
334+
warnings.filterwarnings('error', category=DeprecationWarning)
335+
336+
argv, plugins = self.prepare_test_args(label, verbose, extra_argv,
337+
doctests, coverage)
338+
from noseclasses import NumpyTestProgram
339+
t = NumpyTestProgram(argv=argv, exit=False, plugins=plugins)
340+
finally:
341+
warn_ctx.__exit__()
342+
330343
return t.result
331344

332345
def bench(self, label='fast', verbose=1, extra_argv=None):

0 commit comments

Comments
 (0)
0