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

Method test_context_manager

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

Source from the content-addressed store, hash-verified

809 "assert_warns does not preserver warnings state")
810
811 def test_context_manager(self):
812
813 before_filters = sys.modules['warnings'].filters[:]
814 with assert_warns(UserWarning):
815 warnings.warn("yo")
816 after_filters = sys.modules['warnings'].filters
817
818 def no_warnings():
819 with assert_no_warnings():
820 warnings.warn("yo")
821
822 assert_raises(AssertionError, no_warnings)
823 assert_equal(before_filters, after_filters,
824 "assert_warns does not preserver warnings state")
825
826 def test_warn_wrong_warning(self):
827 def f():

Callers

nothing calls this directly

Calls 4

assert_warnsFunction · 0.90
assert_raisesFunction · 0.90
assert_equalFunction · 0.90
warnMethod · 0.80

Tested by

no test coverage detected