Skip to content

Commit 34df94d

Browse files
committed
TST: Test that assert_warns is reset internally
1 parent 859992a commit 34df94d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sklearn/utils/tests/test_testing.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@ def _raise_ValueError(message):
8585

8686

8787
# This class is inspired from numpy 1.7 with an alteration to check
88-
# the emptied warning filters after calls to assert_warns.
88+
# the reset warning filters after calls to assert_warns.
89+
# This assert_warns behavior is specific to scikit-learn.
8990
class TestWarns(unittest.TestCase):
9091
def test_warn(self):
9192
def f():
9293
warnings.warn("yo")
9394
return 3
9495

96+
# Test that assert_warns is not impacted by externally set
97+
# filters and is reset internally.
98+
warnings.simplefilter("ignore", UserWarning)
9599
assert_equal(assert_warns(UserWarning, f), 3)
96100

97101
# Test that the warning registry is empty after assert_warns

0 commit comments

Comments
 (0)