MCPcopy Index your code
hub / github.com/numpy/numpy / test_args

Method test_args

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

Source from the content-addressed store, hash-verified

1186 "assert_warns does not preserver warnings state")
1187
1188 def test_args(self):
1189 def f(a=0, b=1):
1190 warnings.warn("yo")
1191 return a + b
1192
1193 assert assert_warns(UserWarning, f, b=20) == 20
1194
1195 with pytest.raises(RuntimeError) as exc:
1196 # assert_warns cannot do regexp matching, use pytest.warns
1197 with assert_warns(UserWarning, match="A"):
1198 warnings.warn("B", UserWarning)
1199 assert "assert_warns" in str(exc)
1200 assert "pytest.warns" in str(exc)
1201
1202 with pytest.raises(RuntimeError) as exc:
1203 # assert_warns cannot do regexp matching, use pytest.warns
1204 with assert_warns(UserWarning, wrong="A"):
1205 warnings.warn("B", UserWarning)
1206 assert "assert_warns" in str(exc)
1207 assert "pytest.warns" not in str(exc)
1208
1209 def test_warn_wrong_warning(self):
1210 def f():

Callers

nothing calls this directly

Calls 1

assert_warnsFunction · 0.90

Tested by

no test coverage detected