MCPcopy Create free account
hub / github.com/numpy/numpy / test_warn

Method test_warn

numpy/testing/tests/test_utils.py:795–809  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

793class TestWarns:
794
795 def test_warn(self):
796 def f():
797 warnings.warn("yo")
798 return 3
799
800 before_filters = sys.modules['warnings'].filters[:]
801 assert_equal(assert_warns(UserWarning, f), 3)
802 after_filters = sys.modules['warnings'].filters
803
804 assert_raises(AssertionError, assert_no_warnings, f)
805 assert_equal(assert_no_warnings(lambda x: x, 1), 1)
806
807 # Check that the warnings state is unchanged
808 assert_equal(before_filters, after_filters,
809 "assert_warns does not preserver warnings state")
810
811 def test_context_manager(self):
812

Callers

nothing calls this directly

Calls 4

assert_equalFunction · 0.90
assert_warnsFunction · 0.90
assert_raisesFunction · 0.90
assert_no_warningsFunction · 0.90

Tested by

no test coverage detected