Skip to content

Commit 2bd256b

Browse files
committed
TEST: Catch warnings in clear_and_catch tests
1 parent 7c12c54 commit 2bd256b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

nibabel/tests/test_testing.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_assert_allclose_safely():
6464

6565
def assert_warn_len_equal(mod, n_in_context):
6666
mod_warns = mod.__warningregistry__
67-
# Python 3.4 appears to clear any pre-existing warnings of the same type,
67+
# Python 3 appears to clear any pre-existing warnings of the same type,
6868
# when raising warnings inside a catch_warnings block. So, there is a
6969
# warning generated by the tests within the context manager, but no
7070
# previous warnings.
@@ -84,18 +84,15 @@ def test_clear_and_catch_warnings():
8484
assert_equal(my_mod.__warningregistry__, {})
8585
# Without specified modules, don't clear warnings during context
8686
with clear_and_catch_warnings():
87-
warnings.simplefilter('ignore')
8887
warnings.warn('Some warning')
8988
assert_warn_len_equal(my_mod, 1)
9089
# Confirm that specifying module keeps old warning, does not add new
9190
with clear_and_catch_warnings(modules=[my_mod]):
92-
warnings.simplefilter('ignore')
9391
warnings.warn('Another warning')
9492
assert_warn_len_equal(my_mod, 1)
9593
# Another warning, no module spec does add to warnings dict, except on
96-
# Python 3.4 (see comments in `assert_warn_len_equal`)
94+
# Python 3 (see comments in `assert_warn_len_equal`)
9795
with clear_and_catch_warnings():
98-
warnings.simplefilter('ignore')
9996
warnings.warn('Another warning')
10097
assert_warn_len_equal(my_mod, 2)
10198

0 commit comments

Comments
 (0)