Skip to content

Commit 2663b68

Browse files
committed
DEP: Transition checkwarns to deprecations and set target version
1 parent a3fd7cd commit 2663b68

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

nibabel/checkwarns.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,20 @@
1313
import warnings
1414

1515
from .testing import (error_warnings, suppress_warnings)
16+
from .deprecated import deprecate_with_version
1617

1718

1819
warnings.warn('The checkwarns module is deprecated and will be removed '
19-
'in nibabel v3.0', FutureWarning)
20+
'in nibabel v3.0', DeprecationWarning)
2021

2122

23+
@deprecate_with_version('ErrorWarnings is deprecated; use nibabel.testing.error_warnings.',
24+
since='2.1.0', until='3.0.0')
2225
class ErrorWarnings(error_warnings):
23-
24-
def __init__(self, *args, **kwargs):
25-
warnings.warn('ErrorWarnings is deprecated and will be removed in '
26-
'nibabel v3.0; use nibabel.testing.error_warnings.',
27-
FutureWarning)
28-
super(ErrorWarnings, self).__init__(*args, **kwargs)
26+
pass
2927

3028

29+
@deprecate_with_version('IgnoreWarnings is deprecated; use nibabel.testing.suppress_warnings.',
30+
since='2.1.0', until='3.0.0')
3131
class IgnoreWarnings(suppress_warnings):
32-
33-
def __init__(self, *args, **kwargs):
34-
warnings.warn('IgnoreWarnings is deprecated and will be removed in '
35-
'nibabel v3.0; use nibabel.testing.suppress_warnings.',
36-
FutureWarning)
37-
super(IgnoreWarnings, self).__init__(*args, **kwargs)
32+
pass

nibabel/tests/test_checkwarns.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
""" Tests for warnings context managers
22
"""
3-
from __future__ import division, print_function, absolute_import
4-
5-
from nose.tools import assert_equal
6-
from ..testing import clear_and_catch_warnings, suppress_warnings
3+
from ..testing import assert_equal, assert_warns, suppress_warnings
74

85

96
def test_ignore_and_error_warnings():
107
with suppress_warnings():
118
from .. import checkwarns
129

13-
with clear_and_catch_warnings() as w:
10+
with assert_warns(DeprecationWarning):
1411
checkwarns.IgnoreWarnings()
15-
assert_equal(len(w), 1)
16-
assert_equal(w[0].category, FutureWarning)
1712

18-
with clear_and_catch_warnings() as w:
13+
with assert_warns(DeprecationWarning):
1914
checkwarns.ErrorWarnings()
20-
assert_equal(len(w), 1)
21-
assert_equal(w[0].category, FutureWarning)

0 commit comments

Comments
 (0)