8000 Ignore FutureWarnings when asserting no-warnings. · scikit-learn/scikit-learn@d6972a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit d6972a9

Browse files
committed
Ignore FutureWarnings when asserting no-warnings.
VisibleDeprecationWarning from Numpy is being ignored already and numpy seems to be moving to FutureWarning as recommended in PEP #565.
1 parent 1eaf5f5 commit d6972a9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sklearn/utils/testing.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def assert_warns(warning_class, func, *args, **kw):
142142
warnings.simplefilter("always")
143143
# Trigger a warning.
144144
result = func(*args, **kw)
145+
w = [e for e in w
146+
if e.category is not FutureWarning]
145147
if hasattr(np, 'VisibleDeprecationWarning'):
146148
# Filter out numpy-specific warnings in numpy >= 1.9
147149
w = [e for e in w
@@ -189,6 +191,9 @@ def assert_warns_message(warning_class, message, func, *args, **kw):
189191
with warnings.catch_warnings(record=True) as w:
190192
# Cause all warnings to always be triggered.
191193
warnings.simplefilter("always")
194+
195+
w = [e for e in w
196+
if e.category is not FutureWarning]
192197
if hasattr(np, 'VisibleDeprecationWarning'):
193198
# Let's not catch the numpy internal DeprecationWarnings
194199
warnings.simplefilter('ignore', np.VisibleDeprecationWarning)
@@ -266,6 +271,8 @@ def assert_no_warnings(func, *args, **kw):
266271
warnings.simplefilter('always')
267272

268273
result = func(*args, **kw)
274+
w = [e for e in w
275+
if e.category is not FutureWarning]
269276
if hasattr(np, 'VisibleDeprecationWarning'):
270277
# Filter out numpy-specific warnings in numpy >= 1.9
271278
w = [e for e in w

0 commit comments

Comments
 (0)
0